

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>pysimm.lmps &mdash; pysimm 0.2 documentation</title>
  

  
  

  

  
  
    

  

  
  
    <link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
  

  

  
    <link rel="top" title="pysimm 0.2 documentation" href="../../index.html"/>
        <link rel="up" title="pysimm" href="../pysimm.html"/> 

  
  <script src="../../_static/js/modernizr.min.js"></script>

</head>

<body class="wy-body-for-nav" role="document">

  <div class="wy-grid-for-nav">

    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search">
          

          
            <a href="../../index.html" class="icon icon-home"> pysimm
          

          
          </a>

          
            
            
              <div class="version">
                0.2
              </div>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
                <ul>
<li class="toctree-l1"><a class="reference internal" href="../../pysimm.html">pysimm package</a></li>
</ul>

            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
        <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
        <a href="../../index.html">pysimm</a>
      </nav>


      
      <div class="wy-nav-content">
        <div class="rst-content">
          





<div role="navigation" aria-label="breadcrumbs navigation">
  <ul class="wy-breadcrumbs">
    <li><a href="../../index.html">Docs</a> &raquo;</li>
      
          <li><a href="../index.html">Module code</a> &raquo;</li>
      
          <li><a href="../pysimm.html">pysimm</a> &raquo;</li>
      
    <li>pysimm.lmps</li>
      <li class="wy-breadcrumbs-aside">
        
          
        
      </li>
  </ul>
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <h1>Source code for pysimm.lmps</h1><div class="highlight"><pre>
<span></span><span class="c1"># ******************************************************************************</span>
<span class="c1"># pysimm.lmps module</span>
<span class="c1"># ******************************************************************************</span>
<span class="c1">#</span>
<span class="c1"># ******************************************************************************</span>
<span class="c1"># License</span>
<span class="c1"># ******************************************************************************</span>
<span class="c1"># The MIT License (MIT)</span>
<span class="c1">#</span>
<span class="c1"># Copyright (c) 2016 Michael E. Fortunato, Coray M. Colina</span>
<span class="c1">#</span>
<span class="c1"># Permission is hereby granted, free of charge, to any person obtaining a copy</span>
<span class="c1"># of this software and associated documentation files (the &quot;Software&quot;), to deal</span>
<span class="c1"># in the Software without restriction, including without limitation the rights</span>
<span class="c1"># to use, copy, modify, merge, publish, distribute, sublicense, and/or sell</span>
<span class="c1"># copies of the Software, and to permit persons to whom the Software is</span>
<span class="c1"># furnished to do so, subject to the following conditions:</span>
<span class="c1">#</span>
<span class="c1"># The above copyright notice and this permission notice shall be included in</span>
<span class="c1"># all copies or substantial portions of the Software.</span>
<span class="c1">#</span>
<span class="c1"># THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR</span>
<span class="c1"># IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,</span>
<span class="c1"># FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE</span>
<span class="c1"># AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER</span>
<span class="c1"># LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,</span>
<span class="c1"># OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN</span>
<span class="c1"># THE SOFTWARE.</span>

<span class="kn">import</span> <span class="nn">shlex</span>
<span class="kn">import</span> <span class="nn">shutil</span>
<span class="kn">from</span> <span class="nn">subprocess</span> <span class="kn">import</span> <span class="n">call</span><span class="p">,</span> <span class="n">Popen</span><span class="p">,</span> <span class="n">PIPE</span>
<span class="kn">from</span> <span class="nn">Queue</span> <span class="kn">import</span> <span class="n">Queue</span><span class="p">,</span> <span class="n">Empty</span>
<span class="kn">from</span> <span class="nn">threading</span> <span class="kn">import</span> <span class="n">Thread</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">sys</span>
<span class="kn">import</span> <span class="nn">json</span>
<span class="kn">from</span> <span class="nn">random</span> <span class="kn">import</span> <span class="n">randint</span>
<span class="kn">from</span> <span class="nn">time</span> <span class="kn">import</span> <span class="n">strftime</span>
<span class="kn">from</span> <span class="nn">StringIO</span> <span class="kn">import</span> <span class="n">StringIO</span>

<span class="k">try</span><span class="p">:</span>
    <span class="kn">import</span> <span class="nn">pandas</span> <span class="kn">as</span> <span class="nn">pd</span>
<span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span>
    <span class="n">pd</span> <span class="o">=</span> <span class="bp">None</span>

<span class="kn">from</span> <span class="nn">pysimm.system</span> <span class="kn">import</span> <span class="n">read_lammps</span>
<span class="kn">from</span> <span class="nn">pysimm.system</span> <span class="kn">import</span> <span class="n">System</span>
<span class="kn">from</span> <span class="nn">pysimm</span> <span class="kn">import</span> <span class="n">error_print</span>
<span class="kn">from</span> <span class="nn">pysimm</span> <span class="kn">import</span> <span class="n">warning_print</span>
<span class="kn">from</span> <span class="nn">pysimm</span> <span class="kn">import</span> <span class="n">verbose_print</span>
<span class="kn">from</span> <span class="nn">pysimm</span> <span class="kn">import</span> <span class="n">debug_print</span>
<span class="kn">from</span> <span class="nn">pysimm.utils</span> <span class="kn">import</span> <span class="n">PysimmError</span><span class="p">,</span> <span class="n">Item</span><span class="p">,</span> <span class="n">ItemContainer</span>

<span class="k">try</span><span class="p">:</span>
    <span class="kn">from</span> <span class="nn">Rappture.tools</span> <span class="kn">import</span> <span class="n">getCommandOutput</span> <span class="k">as</span> <span class="n">RapptureExec</span>
<span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span>
    <span class="k">pass</span>

<span class="n">LAMMPS_EXEC</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;LAMMPS_EXEC&#39;</span><span class="p">)</span>
<span class="n">verbose</span> <span class="o">=</span> <span class="bp">False</span>
<span class="n">templates</span> <span class="o">=</span> <span class="p">{}</span>

<span class="n">FF_SETTINGS</span> <span class="o">=</span> <span class="p">{</span>
    <span class="s1">&#39;dreiding&#39;</span><span class="p">:</span>
        <span class="p">{</span>
            <span class="s1">&#39;pair_style&#39;</span><span class="p">:</span>       <span class="s1">&#39;buck&#39;</span><span class="p">,</span>
            <span class="s1">&#39;bond_style&#39;</span><span class="p">:</span>       <span class="s1">&#39;harmonic&#39;</span><span class="p">,</span>
            <span class="s1">&#39;angle_style&#39;</span><span class="p">:</span>      <span class="s1">&#39;harmonic&#39;</span><span class="p">,</span>
            <span class="s1">&#39;dihedral_style&#39;</span><span class="p">:</span>   <span class="s1">&#39;harmonic&#39;</span><span class="p">,</span>
            <span class="s1">&#39;improper_style&#39;</span><span class="p">:</span>   <span class="s1">&#39;harmonic&#39;</span><span class="p">,</span>
            <span class="s1">&#39;pair_modify&#39;</span><span class="p">:</span>      <span class="p">{</span>
                <span class="s1">&#39;mix&#39;</span><span class="p">:</span> <span class="s1">&#39;arithmetic&#39;</span>
            <span class="p">},</span>
            <span class="s1">&#39;special_bonds&#39;</span><span class="p">:</span>    <span class="s1">&#39;dreiding&#39;</span>
        <span class="p">},</span>
    <span class="s1">&#39;dreiding-lj&#39;</span><span class="p">:</span>
        <span class="p">{</span>
            <span class="s1">&#39;pair_style&#39;</span><span class="p">:</span>       <span class="s1">&#39;lj/cut&#39;</span><span class="p">,</span>
            <span class="s1">&#39;bond_style&#39;</span><span class="p">:</span>       <span class="s1">&#39;harmonic&#39;</span><span class="p">,</span>
            <span class="s1">&#39;angle_style&#39;</span><span class="p">:</span>      <span class="s1">&#39;harmonic&#39;</span><span class="p">,</span>
            <span class="s1">&#39;dihedral_style&#39;</span><span class="p">:</span>   <span class="s1">&#39;harmonic&#39;</span><span class="p">,</span>
            <span class="s1">&#39;improper_style&#39;</span><span class="p">:</span>   <span class="s1">&#39;harmonic&#39;</span><span class="p">,</span>
            <span class="s1">&#39;pair_modify&#39;</span><span class="p">:</span>      <span class="p">{</span>
                <span class="s1">&#39;mix&#39;</span><span class="p">:</span> <span class="s1">&#39;arithmetic&#39;</span>
            <span class="p">},</span>
            <span class="s1">&#39;special_bonds&#39;</span><span class="p">:</span>    <span class="s1">&#39;dreiding&#39;</span>
        <span class="p">},</span>
    <span class="s1">&#39;amber&#39;</span><span class="p">:</span>
        <span class="p">{</span>
            <span class="s1">&#39;pair_style&#39;</span><span class="p">:</span>       <span class="s1">&#39;lj/cut&#39;</span><span class="p">,</span>
            <span class="s1">&#39;bond_style&#39;</span><span class="p">:</span>       <span class="s1">&#39;harmonic&#39;</span><span class="p">,</span>
            <span class="s1">&#39;angle_style&#39;</span><span class="p">:</span>      <span class="s1">&#39;harmonic&#39;</span><span class="p">,</span>
            <span class="s1">&#39;dihedral_style&#39;</span><span class="p">:</span>   <span class="s1">&#39;fourier&#39;</span><span class="p">,</span>
            <span class="s1">&#39;improper_style&#39;</span><span class="p">:</span>   <span class="s1">&#39;cvff&#39;</span><span class="p">,</span>
            <span class="s1">&#39;pair_modify&#39;</span><span class="p">:</span>      <span class="p">{</span>
                <span class="s1">&#39;mix&#39;</span><span class="p">:</span> <span class="s1">&#39;arithmetic&#39;</span>
            <span class="p">},</span>
            <span class="s1">&#39;special_bonds&#39;</span><span class="p">:</span>    <span class="s1">&#39;amber&#39;</span>
        <span class="p">},</span>
    <span class="s1">&#39;pcff&#39;</span><span class="p">:</span>
        <span class="p">{</span>
            <span class="s1">&#39;pair_style&#39;</span><span class="p">:</span>       <span class="s1">&#39;lj/class2&#39;</span><span class="p">,</span>
            <span class="s1">&#39;bond_style&#39;</span><span class="p">:</span>       <span class="s1">&#39;class2&#39;</span><span class="p">,</span>
            <span class="s1">&#39;angle_style&#39;</span><span class="p">:</span>      <span class="s1">&#39;class2&#39;</span><span class="p">,</span>
            <span class="s1">&#39;dihedral_style&#39;</span><span class="p">:</span>   <span class="s1">&#39;class2&#39;</span><span class="p">,</span>
            <span class="s1">&#39;improper_style&#39;</span><span class="p">:</span>   <span class="s1">&#39;class2&#39;</span><span class="p">,</span>
            <span class="s1">&#39;pair_modify&#39;</span><span class="p">:</span>      <span class="p">{</span>
                <span class="s1">&#39;mix&#39;</span><span class="p">:</span> <span class="s1">&#39;sixthpower&#39;</span>
            <span class="p">},</span>
            <span class="s1">&#39;special_bonds&#39;</span><span class="p">:</span>    <span class="s1">&#39;lj/coul 0 0 1&#39;</span>
        <span class="p">},</span>
    <span class="s1">&#39;opls&#39;</span><span class="p">:</span>
        <span class="p">{</span>
            <span class="s1">&#39;pair_style&#39;</span><span class="p">:</span>       <span class="s1">&#39;lj/cut&#39;</span><span class="p">,</span>
            <span class="s1">&#39;bond_style&#39;</span><span class="p">:</span>       <span class="s1">&#39;harmonic&#39;</span><span class="p">,</span>
            <span class="s1">&#39;angle_style&#39;</span><span class="p">:</span>      <span class="s1">&#39;harmonic&#39;</span><span class="p">,</span>
            <span class="s1">&#39;dihedral_style&#39;</span><span class="p">:</span>   <span class="s1">&#39;opls&#39;</span><span class="p">,</span>
            <span class="s1">&#39;improper_style&#39;</span><span class="p">:</span>   <span class="s1">&#39;cvff&#39;</span><span class="p">,</span>
            <span class="s1">&#39;pair_modify&#39;</span><span class="p">:</span>      <span class="p">{</span>
                <span class="s1">&#39;mix&#39;</span><span class="p">:</span> <span class="s1">&#39;geometric&#39;</span>
            <span class="p">},</span>
            <span class="s1">&#39;special_bonds&#39;</span><span class="p">:</span>    <span class="s1">&#39;lj/coul 0 0 0.5&#39;</span>
        <span class="p">},</span>
    <span class="s1">&#39;charmm&#39;</span><span class="p">:</span>
        <span class="p">{</span>
            <span class="s1">&#39;pair_style&#39;</span><span class="p">:</span>       <span class="s1">&#39;lj/charmm&#39;</span><span class="p">,</span>
            <span class="s1">&#39;bond_style&#39;</span><span class="p">:</span>       <span class="s1">&#39;harmonic&#39;</span><span class="p">,</span>
            <span class="s1">&#39;angle_style&#39;</span><span class="p">:</span>      <span class="s1">&#39;charmm&#39;</span><span class="p">,</span>
            <span class="s1">&#39;dihedral_style&#39;</span><span class="p">:</span>   <span class="s1">&#39;charmm&#39;</span><span class="p">,</span>
            <span class="s1">&#39;improper_style&#39;</span><span class="p">:</span>   <span class="s1">&#39;harmonic&#39;</span><span class="p">,</span>
            <span class="s1">&#39;pair_modify&#39;</span><span class="p">:</span>      <span class="p">{</span>
                <span class="s1">&#39;mix&#39;</span><span class="p">:</span> <span class="s1">&#39;arithmetic&#39;</span>
            <span class="p">},</span>
            <span class="s1">&#39;special_bonds&#39;</span><span class="p">:</span>    <span class="s1">&#39;charmm&#39;</span>
        <span class="p">},</span>
    <span class="s1">&#39;trappe/amber&#39;</span><span class="p">:</span>
        <span class="p">{</span>
            <span class="s1">&#39;pair_style&#39;</span><span class="p">:</span>       <span class="s1">&#39;lj/cut&#39;</span><span class="p">,</span>
            <span class="s1">&#39;bond_style&#39;</span><span class="p">:</span>       <span class="s1">&#39;harmonic&#39;</span><span class="p">,</span>
            <span class="s1">&#39;angle_style&#39;</span><span class="p">:</span>      <span class="s1">&#39;harmonic&#39;</span><span class="p">,</span>
            <span class="s1">&#39;dihedral_style&#39;</span><span class="p">:</span>   <span class="s1">&#39;fourier&#39;</span><span class="p">,</span>
            <span class="s1">&#39;improper_style&#39;</span><span class="p">:</span>   <span class="s1">&#39;cvff&#39;</span><span class="p">,</span>
            <span class="s1">&#39;pair_modify&#39;</span><span class="p">:</span>      <span class="p">{</span>
                <span class="s1">&#39;mix&#39;</span><span class="p">:</span> <span class="s1">&#39;arithmetic&#39;</span>
            <span class="p">},</span>
            <span class="s1">&#39;special_bonds&#39;</span><span class="p">:</span>    <span class="s1">&#39;amber&#39;</span>
        <span class="p">}</span>
<span class="p">}</span>

<div class="viewcode-block" id="check_lmps_exec"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.check_lmps_exec">[docs]</a><span class="k">def</span> <span class="nf">check_lmps_exec</span><span class="p">():</span>
    <span class="k">if</span> <span class="n">LAMMPS_EXEC</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
        <span class="k">print</span> <span class="s1">&#39;you must set environment variable LAMMPS_EXEC&#39;</span>
        <span class="k">return</span> <span class="bp">False</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="n">stdout</span><span class="p">,</span> <span class="n">stderr</span> <span class="o">=</span> <span class="n">Popen</span><span class="p">([</span><span class="n">LAMMPS_EXEC</span><span class="p">,</span> <span class="s1">&#39;-e&#39;</span><span class="p">,</span> <span class="s1">&#39;both&#39;</span><span class="p">,</span> <span class="s1">&#39;-l&#39;</span><span class="p">,</span> <span class="s1">&#39;none&#39;</span><span class="p">],</span>
                                   <span class="n">stdin</span><span class="o">=</span><span class="n">PIPE</span><span class="p">,</span> <span class="n">stdout</span><span class="o">=</span><span class="n">PIPE</span><span class="p">,</span>
                                   <span class="n">stderr</span><span class="o">=</span><span class="n">PIPE</span><span class="p">)</span><span class="o">.</span><span class="n">communicate</span><span class="p">()</span>
            <span class="k">if</span> <span class="n">verbose</span><span class="p">:</span>
                <span class="k">print</span> <span class="s1">&#39;using </span><span class="si">%s</span><span class="s1"> LAMMPS machine&#39;</span> <span class="o">%</span> <span class="n">LAMMPS_EXEC</span>
            <span class="k">return</span> <span class="bp">True</span>
        <span class="k">except</span> <span class="ne">OSError</span><span class="p">:</span>
            <span class="k">print</span> <span class="s1">&#39;LAMMPS is not configured properly for one reason or another&#39;</span>
            <span class="k">return</span> <span class="bp">False</span></div>


<div class="viewcode-block" id="Init"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.Init">[docs]</a><span class="k">class</span> <span class="nc">Init</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;pysimm.lmps.Init</span>

<span class="sd">    Template object to contain LAMMPS initialization settings</span>

<span class="sd">    Attributes:</span>
<span class="sd">        forcefield: name of a supported force field; simulation settings will be chosen based on the force field name</span>
<span class="sd">        units: LAMMPS set of units to use during simulation; default=real</span>
<span class="sd">        atom_style: LAMMPS aomt_style to use during simulation; default=full</span>
<span class="sd">        charge: option to define if any particles in system a non-zero charge</span>
<span class="sd">        kspace_style: LAMMPS kspace_style to use during simulation if system has charges; default=pppm 1e-4</span>
<span class="sd">        cutoff: dictionary of cutoff distances for nonbonded interactions; default={&#39;lj&#39;: 12.0, &#39;coul&#39;: 12.0, &#39;inner_lj&#39;: 10.0}</span>
<span class="sd">        pair_style: LAMMPS pair_style to use during simulation</span>
<span class="sd">        bond_style: LAMMPS bond_style to use during simulation</span>
<span class="sd">        angle_style: LAMMPS angle_style to use during simulation</span>
<span class="sd">        dihedral_style: LAMMPS dihedral_style to use during simulation</span>
<span class="sd">        improper_style: LAMMPS improper_style to use during simulation</span>
<span class="sd">        special_bonds: LAMMPS special_bonds to use during simulation</span>
<span class="sd">        pair_modify: LAMMPS pair_modify to use during simulation</span>
<span class="sd">        read_data: name of data file to read instead of using :class:`~pysimm.system.System` object</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">forcefield</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;forcefield&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">units</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;units&#39;</span><span class="p">,</span> <span class="s1">&#39;real&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">atom_style</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;atom_style&#39;</span><span class="p">,</span> <span class="s1">&#39;full&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">charge</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;charge&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">kspace_style</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;kspace_style&#39;</span><span class="p">,</span> <span class="s1">&#39;pppm 1e-4&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">cutoff</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;cutoff&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">pair_style</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;pair_style&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">bond_style</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;bond_style&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">angle_style</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;angle_style&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">dihedral_style</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;dihedral_style&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">improper_style</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;improper_style&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">special_bonds</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;special_bonds&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">pair_modify</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;pair_modify&#39;</span><span class="p">,</span> <span class="p">{})</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">create_box</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;create_box&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">read_data</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;read_data&#39;</span><span class="p">)</span>
        
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">forcefield</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">forcefield</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">&#39;amber&#39;</span><span class="p">,</span> <span class="s1">&#39;trappe/amber&#39;</span><span class="p">,</span> <span class="s1">&#39;dreiding&#39;</span><span class="p">,</span> <span class="s1">&#39;pcff&#39;</span><span class="p">,</span> <span class="s1">&#39;opls&#39;</span><span class="p">,</span> <span class="s1">&#39;charmm&#39;</span><span class="p">]:</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">forcefield</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">&#39;gaff&#39;</span><span class="p">,</span> <span class="s1">&#39;gaff2&#39;</span><span class="p">]:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">forcefield</span> <span class="o">=</span> <span class="s1">&#39;amber&#39;</span>
            <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">forcefield</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">&#39;cgenff&#39;</span><span class="p">]:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">forcefield</span> <span class="o">=</span> <span class="s1">&#39;charmm&#39;</span>

        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">cutoff</span><span class="p">,</span> <span class="nb">int</span><span class="p">)</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">cutoff</span><span class="p">,</span> <span class="nb">float</span><span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">cutoff</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;lj&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">cutoff</span><span class="p">,</span> <span class="s1">&#39;coul&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">cutoff</span><span class="p">,</span> <span class="s1">&#39;inner_lj&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">cutoff</span><span class="o">-</span><span class="mf">2.0</span><span class="p">}</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">cutoff</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">cutoff</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;lj&#39;</span><span class="p">:</span> <span class="mf">12.0</span><span class="p">,</span> <span class="s1">&#39;coul&#39;</span><span class="p">:</span> <span class="mf">12.0</span><span class="p">,</span> <span class="s1">&#39;inner_lj&#39;</span><span class="p">:</span> <span class="mf">10.0</span><span class="p">}</span>

<div class="viewcode-block" id="Init.write"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.Init.write">[docs]</a>    <span class="k">def</span> <span class="nf">write</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sim</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;pysimm.lmps.Init.write</span>

<span class="sd">        Prepare LAMMPS input with initialization settings</span>

<span class="sd">        Args:</span>
<span class="sd">            sim: :class:`~pysimm.lmps.Simulation` object reference</span>

<span class="sd">        Returns:</span>
<span class="sd">            string of LAMMPS input</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="n">sim</span><span class="p">:</span>
            <span class="n">s</span> <span class="o">=</span> <span class="n">sim</span><span class="o">.</span><span class="n">system</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">s</span> <span class="o">=</span> <span class="bp">None</span>
        
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">forcefield</span> <span class="ow">is</span> <span class="bp">None</span> <span class="ow">and</span> <span class="n">s</span> <span class="ow">and</span> <span class="n">s</span><span class="o">.</span><span class="n">forcefield</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">s</span><span class="o">.</span><span class="n">forcefield</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">&#39;gaff&#39;</span><span class="p">,</span> <span class="s1">&#39;gaff2&#39;</span><span class="p">]:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">forcefield</span> <span class="o">=</span> <span class="s1">&#39;amber&#39;</span>
            <span class="k">elif</span> <span class="n">s</span><span class="o">.</span><span class="n">forcefield</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">&#39;cgenff&#39;</span><span class="p">]:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">forcefield</span> <span class="o">=</span> <span class="s1">&#39;charmm&#39;</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">forcefield</span> <span class="o">=</span> <span class="n">s</span><span class="o">.</span><span class="n">forcefield</span>
        <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">forcefield</span> <span class="ow">is</span> <span class="bp">None</span> <span class="ow">and</span> <span class="n">sim</span> <span class="ow">and</span> <span class="n">sim</span><span class="o">.</span><span class="n">forcefield</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">forcefield</span> <span class="o">=</span> <span class="n">sim</span><span class="o">.</span><span class="n">forcefield</span>
            
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">special_bonds</span> <span class="ow">is</span> <span class="bp">None</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">forcefield</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">special_bonds</span> <span class="o">=</span> <span class="n">FF_SETTINGS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">forcefield</span><span class="p">][</span><span class="s1">&#39;special_bonds&#39;</span><span class="p">]</span>
        
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">forcefield</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
            <span class="n">pair_modify</span> <span class="o">=</span> <span class="n">FF_SETTINGS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">forcefield</span><span class="p">][</span><span class="s1">&#39;pair_modify&#39;</span><span class="p">]</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pair_modify</span><span class="p">:</span>
                <span class="n">pair_modify</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">pair_modify</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">pair_modify</span> <span class="o">=</span> <span class="n">pair_modify</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">charge</span> <span class="ow">is</span> <span class="bp">None</span> <span class="ow">and</span> <span class="n">s</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">s</span><span class="o">.</span><span class="n">particles</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">p</span><span class="o">.</span><span class="n">charge</span><span class="p">:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">charge</span> <span class="o">=</span> <span class="bp">True</span>
                    <span class="k">break</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">charge</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">charge</span><span class="o">=</span><span class="bp">False</span>

        <span class="n">lammps_input</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
        <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="o">+</span> <span class="s1">&#39;#&#39;</span><span class="o">*</span><span class="mi">80</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span>
        <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;#&#39;</span><span class="o">*</span><span class="mi">34</span> <span class="o">+</span> <span class="s1">&#39;    Init    &#39;</span> <span class="o">+</span> <span class="s1">&#39;#&#39;</span><span class="o">*</span><span class="mi">34</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span>
        <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;#&#39;</span><span class="o">*</span><span class="mi">80</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span>
        <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;{:&lt;15} {}</span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;units&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">units</span><span class="p">)</span>
        <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;{:&lt;15} {}</span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;atom_style&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">atom_style</span><span class="p">)</span>
        
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">create_box</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">create_box</span><span class="o">.</span><span class="n">region</span> <span class="ow">and</span> <span class="nb">type</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">create_box</span><span class="o">.</span><span class="n">region</span><span class="p">)</span> <span class="ow">is</span> <span class="n">Region</span><span class="p">:</span>
            <span class="n">lammps_input</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">create_box</span><span class="o">.</span><span class="n">region</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="bp">None</span><span class="p">)</span>
            <span class="n">lammps_input</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">create_box</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="bp">None</span><span class="p">)</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pair_style</span><span class="p">:</span>
            <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;{:&lt;15} {}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;pair_style&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">pair_style</span><span class="p">)</span>
        <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">forcefield</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">pair_style</span> <span class="o">=</span> <span class="n">FF_SETTINGS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">forcefield</span><span class="p">][</span><span class="s1">&#39;pair_style&#39;</span><span class="p">]</span>
            <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;{:&lt;15} {}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;pair_style&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">pair_style</span><span class="p">)</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">charge</span><span class="p">:</span>
                <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;/coul/long&#39;</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">pair_style</span> <span class="o">+=</span> <span class="s1">&#39;/coul/long&#39;</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">raise</span> <span class="n">PysimmError</span><span class="p">(</span><span class="s1">&#39;A pair_style must be defined during initialization&#39;</span><span class="p">),</span> <span class="bp">None</span><span class="p">,</span> <span class="n">sys</span><span class="o">.</span><span class="n">exc_info</span><span class="p">()[</span><span class="mi">2</span><span class="p">]</span>
            
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">cutoff</span><span class="p">:</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">forcefield</span> <span class="o">==</span> <span class="p">[</span><span class="s1">&#39;charmm&#39;</span><span class="p">]</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">cutoff</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;inner_lj&#39;</span><span class="p">):</span>
                <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39; {} &#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">cutoff</span><span class="p">[</span><span class="s1">&#39;inner_lj&#39;</span><span class="p">])</span>
            <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39; {} &#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">cutoff</span><span class="p">[</span><span class="s1">&#39;lj&#39;</span><span class="p">])</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">charge</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">cutoff</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;coul&#39;</span><span class="p">):</span>
                <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39; {} &#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">cutoff</span><span class="p">[</span><span class="s1">&#39;coul&#39;</span><span class="p">])</span>
        <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span>
        
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">charge</span><span class="p">:</span>
            <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;{:&lt;15} {}</span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;kspace_style&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">kspace_style</span><span class="p">)</span>
        
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">bond_style</span> <span class="ow">is</span> <span class="bp">None</span> <span class="ow">and</span> <span class="n">s</span> <span class="ow">and</span> <span class="n">s</span><span class="o">.</span><span class="n">bonds</span><span class="o">.</span><span class="n">count</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">forcefield</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">bond_style</span> <span class="o">=</span> <span class="n">FF_SETTINGS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">forcefield</span><span class="p">][</span><span class="s1">&#39;bond_style&#39;</span><span class="p">]</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">bond_style</span><span class="p">:</span>
            <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;{:&lt;15} {}</span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;bond_style&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">bond_style</span><span class="p">)</span>
            
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">angle_style</span> <span class="ow">is</span> <span class="bp">None</span> <span class="ow">and</span> <span class="n">s</span> <span class="ow">and</span> <span class="n">s</span><span class="o">.</span><span class="n">angles</span><span class="o">.</span><span class="n">count</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">forcefield</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">angle_style</span> <span class="o">=</span> <span class="n">FF_SETTINGS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">forcefield</span><span class="p">][</span><span class="s1">&#39;angle_style&#39;</span><span class="p">]</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">angle_style</span><span class="p">:</span>
            <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;{:&lt;15} {}</span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;angle_style&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">angle_style</span><span class="p">)</span>
            
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dihedral_style</span> <span class="ow">is</span> <span class="bp">None</span> <span class="ow">and</span> <span class="n">s</span> <span class="ow">and</span> <span class="n">s</span><span class="o">.</span><span class="n">dihedrals</span><span class="o">.</span><span class="n">count</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">forcefield</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">dihedral_style</span> <span class="o">=</span> <span class="n">FF_SETTINGS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">forcefield</span><span class="p">][</span><span class="s1">&#39;dihedral_style&#39;</span><span class="p">]</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dihedral_style</span><span class="p">:</span>
            <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;{:&lt;15} {}</span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;dihedral_style&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">dihedral_style</span><span class="p">)</span>
            
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">improper_style</span> <span class="ow">is</span> <span class="bp">None</span> <span class="ow">and</span> <span class="n">s</span> <span class="ow">and</span> <span class="n">s</span><span class="o">.</span><span class="n">impropers</span><span class="o">.</span><span class="n">count</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">forcefield</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">improper_style</span> <span class="o">=</span> <span class="n">FF_SETTINGS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">forcefield</span><span class="p">][</span><span class="s1">&#39;improper_style&#39;</span><span class="p">]</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">improper_style</span><span class="p">:</span>
            <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;{:&lt;15} {}</span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;improper_style&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">improper_style</span><span class="p">)</span>
            
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">special_bonds</span><span class="p">:</span>
            <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;{:&lt;15} {}</span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;special_bonds&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">special_bonds</span><span class="p">)</span>
        
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pair_modify</span><span class="p">:</span>
            <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;{:&lt;15} &#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;pair_modify&#39;</span><span class="p">)</span>
            <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">pair_modify</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
                <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;{} {} &#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span>
            <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span>
            
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">read_data</span><span class="p">:</span>
            <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;{:&lt;15} {}</span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;read_data&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">read_data</span><span class="p">)</span>
        <span class="k">elif</span> <span class="n">s</span><span class="p">:</span>
            <span class="n">s</span><span class="o">.</span><span class="n">write_lammps</span><span class="p">(</span><span class="s1">&#39;temp.lmps&#39;</span><span class="p">)</span>
            <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;{:&lt;15} temp.lmps</span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;read_data&#39;</span><span class="p">)</span>
            
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">pair_style</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">pair_style</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s1">&#39;buck&#39;</span><span class="p">):</span>
            <span class="k">for</span> <span class="n">pt1</span> <span class="ow">in</span> <span class="n">s</span><span class="o">.</span><span class="n">particle_types</span><span class="p">:</span>
                <span class="k">for</span> <span class="n">pt2</span> <span class="ow">in</span> <span class="n">s</span><span class="o">.</span><span class="n">particle_types</span><span class="p">:</span>
                    <span class="k">if</span> <span class="n">pt1</span><span class="o">.</span><span class="n">tag</span> <span class="o">&lt;=</span> <span class="n">pt2</span><span class="o">.</span><span class="n">tag</span><span class="p">:</span>
                        <span class="n">a</span> <span class="o">=</span> <span class="nb">pow</span><span class="p">(</span><span class="n">pt1</span><span class="o">.</span><span class="n">a</span><span class="o">*</span><span class="n">pt2</span><span class="o">.</span><span class="n">a</span><span class="p">,</span> <span class="mf">0.5</span><span class="p">)</span>
                        <span class="n">c</span> <span class="o">=</span> <span class="nb">pow</span><span class="p">(</span><span class="n">pt1</span><span class="o">.</span><span class="n">c</span><span class="o">*</span><span class="n">pt2</span><span class="o">.</span><span class="n">c</span><span class="p">,</span> <span class="mf">0.5</span><span class="p">)</span>
                        <span class="n">rho</span> <span class="o">=</span> <span class="mf">0.5</span><span class="o">*</span><span class="p">(</span><span class="n">pt1</span><span class="o">.</span><span class="n">rho</span><span class="o">+</span><span class="n">pt2</span><span class="o">.</span><span class="n">rho</span><span class="p">)</span>
                        <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;{:&lt;15} {} {} {} {} {}</span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;pair_coeff&#39;</span><span class="p">,</span> <span class="n">pt1</span><span class="o">.</span><span class="n">tag</span><span class="p">,</span> <span class="n">pt2</span><span class="o">.</span><span class="n">tag</span><span class="p">,</span> <span class="n">a</span><span class="p">,</span> <span class="n">rho</span><span class="p">,</span> <span class="n">c</span><span class="p">)</span>
        
        <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;#&#39;</span><span class="o">*</span><span class="mi">80</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="se">\n\n</span><span class="s1">&#39;</span>
        
        <span class="k">return</span> <span class="n">lammps_input</span></div></div>
        
        
<div class="viewcode-block" id="Region"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.Region">[docs]</a><span class="k">class</span> <span class="nc">Region</span><span class="p">(</span><span class="n">Item</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;pysimm.lmps.Region</span>

<span class="sd">    Template object to create a region in a LAMMPS simulation. See LAMMPS documentation for further information</span>

<span class="sd">    Attributes:</span>
<span class="sd">        name: name id for region</span>
<span class="sd">        style: LAMMPS region style </span>
<span class="sd">        *args: args for given style</span>
<span class="sd">        **kwargs: optional kwargs for region command</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;all&#39;</span><span class="p">,</span> <span class="n">style</span><span class="o">=</span><span class="s1">&#39;block&#39;</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="n">Item</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="n">name</span><span class="p">,</span> <span class="n">style</span><span class="o">=</span><span class="n">style</span><span class="p">,</span> <span class="n">args</span><span class="o">=</span><span class="n">args</span><span class="p">,</span> <span class="n">kwargs</span><span class="o">=</span><span class="n">kwargs</span><span class="p">)</span>
        
<div class="viewcode-block" id="Region.write"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.Region.write">[docs]</a>    <span class="k">def</span> <span class="nf">write</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sim</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
        <span class="n">inp</span> <span class="o">=</span> <span class="s1">&#39;{:&lt;15} {name} {style} &#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;region&#39;</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">style</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">style</span><span class="p">)</span>
        <span class="k">for</span> <span class="n">a</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="p">:</span>
            <span class="n">inp</span> <span class="o">+=</span> <span class="s1">&#39;{} &#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">a</span><span class="p">)</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">_</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">6</span><span class="p">):</span>
                <span class="n">inp</span> <span class="o">+=</span> <span class="s1">&#39;EDGE &#39;</span>
        <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">kwargs</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
            <span class="n">inp</span> <span class="o">+=</span> <span class="s1">&#39;{} {} &#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span>
        <span class="n">inp</span> <span class="o">+=</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span>
        <span class="k">return</span> <span class="n">inp</span></div></div>
        
        
<div class="viewcode-block" id="CreateBox"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.CreateBox">[docs]</a><span class="k">class</span> <span class="nc">CreateBox</span><span class="p">(</span><span class="n">Item</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;pysimm.lmps.CreateBox</span>

<span class="sd">    Template object to create a box in a LAMMPS simulation. See LAMMPS documentation for further information</span>

<span class="sd">    Attributes:</span>
<span class="sd">        n: number of atom types</span>
<span class="sd">        region: :class:`~pysimm.lmps.Region` object</span>
<span class="sd">        **kwargs: optional kwargs for create_box command (replace / with _)</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">n</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">region</span><span class="o">=</span><span class="n">Region</span><span class="p">(),</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="n">Item</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">n</span><span class="o">=</span><span class="n">n</span><span class="p">,</span> <span class="n">region</span><span class="o">=</span><span class="n">region</span><span class="p">,</span> <span class="n">args</span><span class="o">=</span><span class="n">args</span><span class="p">,</span> <span class="n">kwargs</span><span class="o">=</span><span class="n">kwargs</span><span class="p">)</span>
        
<div class="viewcode-block" id="CreateBox.write"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.CreateBox.write">[docs]</a>    <span class="k">def</span> <span class="nf">write</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sim</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
        <span class="n">inp</span> <span class="o">=</span> <span class="s1">&#39;{:&lt;15} {n} {region.name} &#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;create_box&#39;</span><span class="p">,</span> <span class="o">**</span><span class="nb">vars</span><span class="p">(</span><span class="bp">self</span><span class="p">))</span>
        <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">kwargs</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
            <span class="n">inp</span> <span class="o">+=</span> <span class="s1">&#39;{} {} &#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">k</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">&#39;_&#39;</span><span class="p">,</span> <span class="s1">&#39;/&#39;</span><span class="p">),</span> <span class="n">v</span><span class="p">)</span>
        <span class="n">inp</span> <span class="o">+=</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span>
        <span class="k">return</span> <span class="n">inp</span></div></div>


<div class="viewcode-block" id="Group"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.Group">[docs]</a><span class="k">class</span> <span class="nc">Group</span><span class="p">(</span><span class="n">Item</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;pysimm.lmps.Group</span>

<span class="sd">    Template object to define a group in a LAMMPS simulation. See LAMMPS documentation for further information</span>

<span class="sd">    Attributes:</span>
<span class="sd">        name: name for the group</span>
<span class="sd">        style: style for the group</span>
<span class="sd">        *args: arguments for the given style</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;all&#39;</span><span class="p">,</span> <span class="n">style</span><span class="o">=</span><span class="s1">&#39;id&#39;</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="n">Item</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="n">name</span><span class="p">,</span> <span class="n">style</span><span class="o">=</span><span class="n">style</span><span class="p">,</span> <span class="n">args</span><span class="o">=</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
        
<div class="viewcode-block" id="Group.write"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.Group.write">[docs]</a>    <span class="k">def</span> <span class="nf">write</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sim</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
        <span class="n">inp</span> <span class="o">=</span> <span class="s1">&#39;{:&lt;15} {name} {style} &#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;group&#39;</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">style</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">style</span><span class="p">)</span>
        <span class="k">for</span> <span class="n">a</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="p">:</span>
            <span class="n">inp</span> <span class="o">+=</span> <span class="s1">&#39;{} &#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">a</span><span class="p">)</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="p">:</span>
            <span class="n">inp</span> <span class="o">+=</span> <span class="s1">&#39;*&#39;</span>
        <span class="n">inp</span> <span class="o">+=</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span>
        <span class="k">return</span> <span class="n">inp</span></div></div>
        

<div class="viewcode-block" id="Velocity"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.Velocity">[docs]</a><span class="k">class</span> <span class="nc">Velocity</span><span class="p">(</span><span class="n">Item</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;pysimm.lmps.Velocity</span>

<span class="sd">    Template object to define velocity initialization in a LAMMPS simulation. See LAMMPS documentation for further information</span>

<span class="sd">    Attributes:</span>
<span class="sd">        group: group for velocity command</span>
<span class="sd">        style: style for the velocity command</span>
<span class="sd">        *args: arguments for the given style</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">group</span><span class="o">=</span><span class="n">Group</span><span class="p">(</span><span class="s1">&#39;all&#39;</span><span class="p">),</span> <span class="n">style</span><span class="o">=</span><span class="s1">&#39;create&#39;</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="n">Item</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">group</span><span class="o">=</span><span class="n">group</span><span class="p">,</span> <span class="n">style</span><span class="o">=</span><span class="n">style</span><span class="p">,</span> <span class="n">args</span><span class="o">=</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">seed</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">seed</span> <span class="o">=</span> <span class="n">randint</span><span class="p">(</span><span class="mi">10000</span><span class="p">,</span> <span class="mi">99999</span><span class="p">)</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">temperature</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">temperature</span> <span class="o">=</span> <span class="mf">300.0</span>
        <span class="k">if</span> <span class="n">args</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">from_args</span> <span class="o">=</span> <span class="bp">True</span>
        
<div class="viewcode-block" id="Velocity.write"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.Velocity.write">[docs]</a>    <span class="k">def</span> <span class="nf">write</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sim</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">group</span><span class="p">,</span> <span class="n">Group</span><span class="p">):</span>
            <span class="n">inp</span> <span class="o">=</span> <span class="s1">&#39;{:&lt;15} {group.name} {style} &#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;velocity&#39;</span><span class="p">,</span> <span class="n">group</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">group</span><span class="p">,</span> <span class="n">style</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">style</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">inp</span> <span class="o">=</span> <span class="s1">&#39;{:&lt;15} {group} {style} &#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;velocity&#39;</span><span class="p">,</span> <span class="n">group</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">group</span><span class="p">,</span> <span class="n">style</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">style</span><span class="p">)</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">from_args</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">a</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">args</span><span class="p">:</span>
                <span class="n">inp</span> <span class="o">+=</span> <span class="s1">&#39;{} &#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">a</span><span class="p">)</span>
        <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">style</span> <span class="o">==</span> <span class="s1">&#39;create&#39;</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">style</span> <span class="o">==</span> <span class="s1">&#39;scale&#39;</span><span class="p">:</span>
            <span class="n">inp</span> <span class="o">+=</span> <span class="s1">&#39;{temp} &#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">temp</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">temperature</span><span class="p">)</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">style</span> <span class="o">==</span> <span class="s1">&#39;create&#39;</span><span class="p">:</span>
                <span class="n">inp</span> <span class="o">+=</span> <span class="s1">&#39;{seed} &#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">seed</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">seed</span><span class="p">)</span>
        <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">&#39;dist&#39;</span><span class="p">,</span> <span class="s1">&#39;sum&#39;</span><span class="p">,</span> <span class="s1">&#39;mom&#39;</span><span class="p">,</span> <span class="s1">&#39;rot&#39;</span><span class="p">,</span> <span class="s1">&#39;bias&#39;</span><span class="p">,</span> <span class="s1">&#39;loop&#39;</span><span class="p">,</span> <span class="s1">&#39;rigid&#39;</span><span class="p">,</span> <span class="s1">&#39;units&#39;</span><span class="p">]:</span>
            <span class="k">if</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">k</span><span class="p">):</span>
                <span class="n">inp</span> <span class="o">+=</span> <span class="s1">&#39;{} {} &#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">k</span><span class="p">))</span>
        <span class="n">inp</span> <span class="o">+=</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span>
        <span class="k">return</span> <span class="n">inp</span></div></div>


<div class="viewcode-block" id="OutputSettings"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.OutputSettings">[docs]</a><span class="k">class</span> <span class="nc">OutputSettings</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;pysimm.lmps.OutputSettings</span>

<span class="sd">    Template object to define thermo and dump output settings in a LAMMPS simulation. See LAMMPS documentation for further information</span>

<span class="sd">    Attributes:</span>
<span class="sd">        thermo: dictionary of settings for thermo output</span>
<span class="sd">        dump: dictionary of settings for dump output</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">thermo</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;thermo&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">dump</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;dump&#39;</span><span class="p">,</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;trajectory&#39;</span><span class="p">))</span>
        
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">thermo</span><span class="p">,</span> <span class="nb">int</span><span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">thermo</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;freq&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">thermo</span><span class="p">}</span>
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">thermo</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">thermo</span><span class="p">[</span><span class="s1">&#39;freq&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">thermo</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;freq&#39;</span><span class="p">,</span> <span class="mi">1000</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">thermo</span><span class="p">[</span><span class="s1">&#39;style&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">thermo</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;style&#39;</span><span class="p">,</span> <span class="s1">&#39;custom&#39;</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">thermo</span><span class="p">[</span><span class="s1">&#39;args&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">thermo</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;args&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;step&#39;</span><span class="p">,</span> <span class="s1">&#39;time&#39;</span><span class="p">,</span> <span class="s1">&#39;temp&#39;</span><span class="p">,</span> <span class="s1">&#39;vol&#39;</span><span class="p">,</span> <span class="s1">&#39;press&#39;</span><span class="p">,</span> <span class="s1">&#39;etotal&#39;</span><span class="p">,</span> <span class="s1">&#39;epair&#39;</span><span class="p">,</span> <span class="s1">&#39;emol&#39;</span><span class="p">,</span> <span class="s1">&#39;density&#39;</span><span class="p">])</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">thermo</span><span class="p">[</span><span class="s1">&#39;modify&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">thermo</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;modify&#39;</span><span class="p">)</span>
            
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dump</span><span class="p">,</span> <span class="nb">int</span><span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">dump</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;freq&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">dump</span><span class="p">}</span>
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dump</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">dump</span><span class="p">[</span><span class="s1">&#39;freq&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">dump</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;freq&#39;</span><span class="p">,</span> <span class="mi">1000</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">dump</span><span class="p">[</span><span class="s1">&#39;group&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">dump</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;group&#39;</span><span class="p">,</span> <span class="n">Group</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s1">&#39;all&#39;</span><span class="p">))</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">dump</span><span class="p">[</span><span class="s1">&#39;name&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">dump</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;name&#39;</span><span class="p">,</span> <span class="s1">&#39;pysimm_dump&#39;</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">dump</span><span class="p">[</span><span class="s1">&#39;style&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">dump</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;style&#39;</span><span class="p">,</span> <span class="s1">&#39;custom&#39;</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">dump</span><span class="p">[</span><span class="s1">&#39;filename&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">dump</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;filename&#39;</span><span class="p">,</span> <span class="s1">&#39;dump.*&#39;</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">dump</span><span class="p">[</span><span class="s1">&#39;args&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">dump</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;args&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;id&#39;</span><span class="p">,</span> <span class="s1">&#39;type&#39;</span><span class="p">,</span> <span class="s1">&#39;mol&#39;</span><span class="p">,</span> <span class="s1">&#39;x&#39;</span><span class="p">,</span> <span class="s1">&#39;y&#39;</span><span class="p">,</span> <span class="s1">&#39;z&#39;</span><span class="p">,</span> <span class="s1">&#39;vx&#39;</span><span class="p">,</span> <span class="s1">&#39;vy&#39;</span><span class="p">,</span> <span class="s1">&#39;vz&#39;</span><span class="p">])</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">dump</span><span class="p">[</span><span class="s1">&#39;modify&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">dump</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;modify&#39;</span><span class="p">)</span>
        
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dump</span><span class="p">,</span> <span class="nb">dict</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dump</span><span class="p">[</span><span class="s1">&#39;group&#39;</span><span class="p">],</span> <span class="nb">basestring</span><span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">dump</span><span class="p">[</span><span class="s1">&#39;group&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">Group</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">dump</span><span class="p">[</span><span class="s1">&#39;group&#39;</span><span class="p">])</span>
            
<div class="viewcode-block" id="OutputSettings.write"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.OutputSettings.write">[docs]</a>    <span class="k">def</span> <span class="nf">write</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sim</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
        <span class="n">lammps_input</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
            
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">thermo</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span>
            <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="o">+</span> <span class="s1">&#39;#&#39;</span><span class="o">*</span><span class="mi">80</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span>
            <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;#&#39;</span><span class="o">*</span><span class="mi">29</span> <span class="o">+</span> <span class="s1">&#39;    Thermo  output    &#39;</span> <span class="o">+</span> <span class="s1">&#39;#&#39;</span><span class="o">*</span><span class="mi">29</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span>
            <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;#&#39;</span><span class="o">*</span><span class="mi">80</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span>
            <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;{:&lt;15} {}</span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;thermo&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">thermo</span><span class="p">[</span><span class="s1">&#39;freq&#39;</span><span class="p">])</span>
            <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;{:&lt;15} {} &#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;thermo_style&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">thermo</span><span class="p">[</span><span class="s1">&#39;style&#39;</span><span class="p">])</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">thermo</span><span class="p">[</span><span class="s1">&#39;style&#39;</span><span class="p">]</span> <span class="o">==</span> <span class="s1">&#39;custom&#39;</span><span class="p">:</span>
                <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39; &#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">thermo</span><span class="p">[</span><span class="s1">&#39;args&#39;</span><span class="p">])</span>
            <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">thermo</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;modify&#39;</span><span class="p">):</span>
                <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;{:&lt;15} {} &#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;thermo_modify&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">thermo</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;modify&#39;</span><span class="p">))</span>
                <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span>
            <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;#&#39;</span><span class="o">*</span><span class="mi">80</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="se">\n\n</span><span class="s1">&#39;</span>
        
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dump</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span>
            <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="o">+</span> <span class="s1">&#39;#&#39;</span><span class="o">*</span><span class="mi">80</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span>
            <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;#&#39;</span><span class="o">*</span><span class="mi">30</span> <span class="o">+</span> <span class="s1">&#39;    Dump  output    &#39;</span> <span class="o">+</span> <span class="s1">&#39;#&#39;</span><span class="o">*</span><span class="mi">30</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span>
            <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;#&#39;</span><span class="o">*</span><span class="mi">80</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span>
            <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;{:&lt;15} {} {} {} {} {} &#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;dump&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">dump</span><span class="p">[</span><span class="s1">&#39;name&#39;</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">dump</span><span class="p">[</span><span class="s1">&#39;group&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">dump</span><span class="p">[</span><span class="s1">&#39;style&#39;</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">dump</span><span class="p">[</span><span class="s1">&#39;freq&#39;</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">dump</span><span class="p">[</span><span class="s1">&#39;filename&#39;</span><span class="p">])</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dump</span><span class="p">[</span><span class="s1">&#39;style&#39;</span><span class="p">]</span> <span class="o">==</span> <span class="s1">&#39;custom&#39;</span><span class="p">:</span>
                <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39; &#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dump</span><span class="p">[</span><span class="s1">&#39;args&#39;</span><span class="p">])</span>
            <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dump</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;modify&#39;</span><span class="p">):</span>
                <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;{:&lt;15} {} {} &#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;dump_modify&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">dump</span><span class="p">[</span><span class="s1">&#39;name&#39;</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">dump</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;modify&#39;</span><span class="p">))</span>
                <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span>
            <span class="n">lammps_input</span> <span class="o">+=</span> <span class="s1">&#39;#&#39;</span><span class="o">*</span><span class="mi">80</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="se">\n\n</span><span class="s1">&#39;</span>
        <span class="k">return</span> <span class="n">lammps_input</span></div></div>
            

<div class="viewcode-block" id="Qeq"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.Qeq">[docs]</a><span class="k">class</span> <span class="nc">Qeq</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;pysimm.lmps.MolecularDynamics</span>

<span class="sd">    Template object to contain LAMMPS qeq settings</span>

<span class="sd">    Attributes:</span>
<span class="sd">        cutoff: distance cutoff for charge equilibration</span>
<span class="sd">        tol: tolerance (precision) for charge equilibration</span>
<span class="sd">        max_iter: maximum iterations</span>
<span class="sd">        qfile: file with qeq parameters (leave undefined for defaults)</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">cutoff</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;cutoff&#39;</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">tol</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;tol&#39;</span><span class="p">,</span> <span class="mf">1.0e-6</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">max_iter</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;max_iter&#39;</span><span class="p">,</span> <span class="mi">200</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">qfile</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;qfile&#39;</span><span class="p">)</span>
        
        <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
        
<div class="viewcode-block" id="Qeq.write"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.Qeq.write">[docs]</a>    <span class="k">def</span> <span class="nf">write</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sim</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;pysimm.lmps.Qeq.write</span>

<span class="sd">        Create LAMMPS input for a charge equilibration calculation</span>

<span class="sd">        Args:</span>
<span class="sd">            sim: :class:`~pysimm.lmps.Simulation` object reference</span>

<span class="sd">        Returns:</span>
<span class="sd">            input string</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">qfile</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
            <span class="n">param_file</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">dirname</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">realpath</span><span class="p">(</span><span class="vm">__file__</span><span class="p">)),</span>
                                      <span class="n">os</span><span class="o">.</span><span class="n">pardir</span><span class="p">,</span> <span class="s1">&#39;dat&#39;</span><span class="p">,</span> <span class="s1">&#39;qeq&#39;</span><span class="p">,</span> <span class="s1">&#39;hcno.json&#39;</span><span class="p">)</span>
            <span class="k">with</span> <span class="nb">file</span><span class="p">(</span><span class="n">param_file</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
                <span class="n">qeq_params</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">loads</span><span class="p">(</span><span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">())</span>
            <span class="k">with</span> <span class="nb">file</span><span class="p">(</span><span class="s1">&#39;pysimm.qeq.tmp&#39;</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
                <span class="k">for</span> <span class="n">pt</span> <span class="ow">in</span> <span class="n">sim</span><span class="o">.</span><span class="n">system</span><span class="o">.</span><span class="n">particle_types</span><span class="p">:</span>
                    <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s1">&#39;{}</span><span class="se">\t</span><span class="s1">{}</span><span class="se">\t</span><span class="s1">{}</span><span class="se">\t</span><span class="s1">{}</span><span class="se">\t</span><span class="s1">{}</span><span class="se">\t</span><span class="s1">{}</span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">pt</span><span class="o">.</span><span class="n">tag</span><span class="p">,</span> 
                                                  <span class="n">qeq_params</span><span class="p">[</span><span class="n">pt</span><span class="o">.</span><span class="n">elem</span><span class="p">][</span><span class="s1">&#39;chi&#39;</span><span class="p">],</span>
                                                  <span class="n">qeq_params</span><span class="p">[</span><span class="n">pt</span><span class="o">.</span><span class="n">elem</span><span class="p">][</span><span class="s1">&#39;eta&#39;</span><span class="p">]</span><span class="o">*</span><span class="mi">2</span><span class="p">,</span>
                                                  <span class="n">qeq_params</span><span class="p">[</span><span class="n">pt</span><span class="o">.</span><span class="n">elem</span><span class="p">][</span><span class="s1">&#39;gamma&#39;</span><span class="p">],</span>
                                                  <span class="n">qeq_params</span><span class="p">[</span><span class="n">pt</span><span class="o">.</span><span class="n">elem</span><span class="p">][</span><span class="s1">&#39;zeta&#39;</span><span class="p">],</span>
                                                  <span class="n">qeq_params</span><span class="p">[</span><span class="n">pt</span><span class="o">.</span><span class="n">elem</span><span class="p">][</span><span class="s1">&#39;qcore&#39;</span><span class="p">]))</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">qfile</span> <span class="o">=</span> <span class="s1">&#39;pysimm.qeq.tmp&#39;</span>
        
        <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">+=</span> <span class="s1">&#39;fix 1 all qeq/point 1 {} {} {} {}</span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">cutoff</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">tol</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">max_iter</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">qfile</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">+=</span> <span class="s1">&#39;run 0</span><span class="se">\n</span><span class="s1">&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">+=</span> <span class="s1">&#39;unfix 1</span><span class="se">\n</span><span class="s1">&#39;</span>
        
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">input</span></div></div>
        
    
<div class="viewcode-block" id="MolecularDynamics"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.MolecularDynamics">[docs]</a><span class="k">class</span> <span class="nc">MolecularDynamics</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;pysimm.lmps.MolecularDynamics</span>

<span class="sd">    Template object to contain LAMMPS MD settings</span>

<span class="sd">    Attributes:</span>
<span class="sd">        name: name to identify MD</span>
<span class="sd">        group: :class:`~pysimm.lmps.Group` object for integrator</span>
<span class="sd">        timestep: timestep value to use during MD</span>
<span class="sd">        ensemble: &#39;nvt&#39; or &#39;npt&#39; or &#39;nve&#39;; default=nve</span>
<span class="sd">        limit: numerical value to use with nve when limiting particle displacement</span>
<span class="sd">        temperature: dictionary of settings for temperature (start, stop, damp)</span>
<span class="sd">        pressure: dictionary of settings for pressure (start, stop, damp)</span>
<span class="sd">        run: length of MD simulation in number of timesteps or False to omit run command</span>
<span class="sd">        unfix: True to include command to unfix integrator after run</span>
<span class="sd">        rigid: dictionary of settings for a rigid simulation</span>
<span class="sd">        extra_keywords: dictionary of extra keywords to append at the end of the LAMMPS fix integrator</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;name&#39;</span><span class="p">,</span> <span class="s1">&#39;pysimm_md&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">group</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;group&#39;</span><span class="p">,</span> <span class="n">Group</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s1">&#39;all&#39;</span><span class="p">))</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">timestep</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;timestep&#39;</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">ensemble</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;ensemble&#39;</span><span class="p">,</span> <span class="s1">&#39;nve&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">limit</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;limit&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">temperature</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;temperature&#39;</span><span class="p">,</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;temp&#39;</span><span class="p">,</span> <span class="mf">300.</span><span class="p">))</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">pressure</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;pressure&#39;</span><span class="p">,</span> <span class="mf">1.</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">run</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;run&#39;</span><span class="p">,</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;length&#39;</span><span class="p">,</span> <span class="mi">2000</span><span class="p">))</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">unfix</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;unfix&#39;</span><span class="p">,</span> <span class="bp">True</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">rigid</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;rigid&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">extra_keywords</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;extra_keywords&#39;</span><span class="p">,</span> <span class="p">{})</span>
        
        <span class="k">if</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;temp&#39;</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
            <span class="k">print</span><span class="p">(</span><span class="s1">&#39;temp keyword argument is deprecated for MolecularDynamics, please use temperature instead&#39;</span><span class="p">)</span>
        
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">group</span><span class="p">,</span> <span class="nb">basestring</span><span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">group</span> <span class="o">=</span> <span class="n">Group</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">group</span><span class="p">)</span>
        
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">temperature</span><span class="p">,</span> <span class="nb">int</span><span class="p">)</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">temperature</span><span class="p">,</span> <span class="nb">float</span><span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">temperature</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;start&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">temperature</span><span class="p">}</span>
            
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">pressure</span><span class="p">,</span> <span class="nb">int</span><span class="p">)</span> <span class="ow">or</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">pressure</span><span class="p">,</span> <span class="nb">float</span><span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">pressure</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;start&#39;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">pressure</span><span class="p">}</span>
            
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">rigid</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">ensemble</span> <span class="o">=</span> <span class="s1">&#39;rigid/{}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">ensemble</span><span class="p">)</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">rigid</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;small&#39;</span><span class="p">):</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">ensemble</span> <span class="o">+=</span> <span class="s1">&#39;/small &#39;</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>

<div class="viewcode-block" id="MolecularDynamics.write"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.MolecularDynamics.write">[docs]</a>    <span class="k">def</span> <span class="nf">write</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sim</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;pysimm.lmps.MolecularDynamics.write</span>

<span class="sd">        Create LAMMPS input for a molecular dynamics simulation.</span>

<span class="sd">        Args:</span>
<span class="sd">            sim: pysimm.lmps.Simulation object reference</span>

<span class="sd">        Returns:</span>
<span class="sd">            input string</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">+=</span> <span class="s1">&#39;{:&lt;15} {}</span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;timestep&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">timestep</span><span class="p">)</span>
        
        <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">+=</span> <span class="s1">&#39;{:&lt;15} {} {} {}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;fix&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">group</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">ensemble</span><span class="p">)</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ensemble</span> <span class="o">==</span> <span class="s1">&#39;nve&#39;</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">limit</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">+=</span> <span class="s1">&#39;/limit {} &#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">limit</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">+=</span> <span class="s1">&#39; &#39;</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">rigid</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">+=</span> <span class="s1">&#39;{} &#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">rigid</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;style&#39;</span><span class="p">,</span> <span class="s1">&#39;molecule&#39;</span><span class="p">))</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">rigid</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;style&#39;</span><span class="p">)</span> <span class="o">==</span> <span class="s1">&#39;group&#39;</span><span class="p">:</span>
                <span class="k">assert</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">rigid</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;groups&#39;</span><span class="p">),</span> <span class="nb">list</span><span class="p">)</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">+=</span> <span class="s1">&#39; {} &#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">rigid</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;groups&#39;</span><span class="p">)))</span>
                <span class="k">for</span> <span class="n">g</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">rigid</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;groups&#39;</span><span class="p">):</span>
                    <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">g</span><span class="p">,</span> <span class="n">Group</span><span class="p">):</span>
                        <span class="n">group_name</span> <span class="o">=</span> <span class="n">g</span><span class="o">.</span><span class="n">name</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="n">group_name</span> <span class="o">=</span> <span class="n">g</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">+=</span> <span class="s1">&#39;{} &#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">group_name</span><span class="p">)</span>
        <span class="k">if</span> <span class="s1">&#39;t&#39;</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">ensemble</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">+=</span> <span class="s1">&#39;temp {} {} {} &#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">temperature</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;start&#39;</span><span class="p">,</span> <span class="mf">300.</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">temperature</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;stop&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">temperature</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;start&#39;</span><span class="p">,</span> <span class="mf">300.</span><span class="p">)),</span> <span class="bp">self</span><span class="o">.</span><span class="n">temperature</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;damp&#39;</span><span class="p">,</span> <span class="mi">100</span><span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">timestep</span><span class="p">))</span>
        <span class="k">if</span> <span class="s1">&#39;p&#39;</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">ensemble</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">+=</span> <span class="s1">&#39;{} {} {} {} &#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">pressure</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;iso&#39;</span><span class="p">,</span> <span class="s1">&#39;aniso&#39;</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">pressure</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;start&#39;</span><span class="p">,</span> <span class="mf">1.</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">pressure</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;stop&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">pressure</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;start&#39;</span><span class="p">,</span> <span class="mf">1.</span><span class="p">)),</span> <span class="bp">self</span><span class="o">.</span><span class="n">pressure</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;damp&#39;</span><span class="p">,</span> <span class="mi">1000</span><span class="o">*</span><span class="bp">self</span><span class="o">.</span><span class="n">timestep</span><span class="p">))</span>
        
        <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">extra_keywords</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">+=</span> <span class="s1">&#39;{} {} &#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span>
        
        <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">+=</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">run</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">False</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">+=</span> <span class="s1">&#39;{:&lt;15} {}</span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="s1">&#39;run&#39;</span><span class="p">,</span> <span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">run</span><span class="p">))</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">run</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">unfix</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">+=</span> <span class="s1">&#39;unfix {}</span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>

        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">input</span></div></div>
        
        
<div class="viewcode-block" id="SteeredMolecularDynamics"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.SteeredMolecularDynamics">[docs]</a><span class="k">class</span> <span class="nc">SteeredMolecularDynamics</span><span class="p">(</span><span class="n">MolecularDynamics</span><span class="p">):</span>
    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="n">MolecularDynamics</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">p1</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;p1&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">p2</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;p2&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">k</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;k&#39;</span><span class="p">,</span> <span class="mf">20.0</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">v</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;v&#39;</span><span class="p">,</span> <span class="mf">0.001</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">d</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;d&#39;</span><span class="p">,</span> <span class="mf">3.0</span><span class="p">)</span>
    
<div class="viewcode-block" id="SteeredMolecularDynamics.write"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.SteeredMolecularDynamics.write">[docs]</a>    <span class="k">def</span> <span class="nf">write</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sim</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;pysimm.lmps.SteeredMolecularDynamics.write</span>

<span class="sd">        Create LAMMPS input for a steered molecular dynamics simulation.</span>

<span class="sd">        Args:</span>
<span class="sd">            sim: :class:`~pysimm.lmps.Simulation` object reference</span>

<span class="sd">        Returns:</span>
<span class="sd">            input string</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">thermo</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">+=</span> <span class="s1">&#39;thermo </span><span class="si">%s</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">thermo</span><span class="p">)</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">thermo_style</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">+=</span> <span class="s1">&#39;thermo_style </span><span class="si">%s</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">thermo_style</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">+=</span> <span class="s1">&#39;timestep </span><span class="si">%s</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">timestep</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ensemble</span> <span class="o">==</span> <span class="s1">&#39;nvt&#39;</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">+=</span> <span class="s1">&#39;fix 1 all </span><span class="si">%s</span><span class="s1"> temp </span><span class="si">%s</span><span class="s1"> </span><span class="si">%s</span><span class="s1"> </span><span class="si">%s</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">ensemble</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">t_start</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">t_stop</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">tdamp</span><span class="p">)</span>
        <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">ensemble</span> <span class="o">==</span> <span class="s1">&#39;npt&#39;</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">+=</span> <span class="p">(</span><span class="s1">&#39;fix 1 all </span><span class="si">%s</span><span class="s1"> temp </span><span class="si">%s</span><span class="s1"> </span><span class="si">%s</span><span class="s1"> </span><span class="si">%s</span><span class="s1"> iso </span><span class="si">%s</span><span class="s1"> </span><span class="si">%s</span><span class="s1"> </span><span class="si">%s</span><span class="se">\n</span><span class="s1">&#39;</span>
                           <span class="o">%</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">ensemble</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">t_start</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">t_stop</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">tdamp</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">p_start</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">p_stop</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">pdamp</span><span class="p">))</span>
        <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">ensemble</span> <span class="o">==</span> <span class="s1">&#39;nve&#39;</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">+=</span> <span class="s1">&#39;fix 1 all </span><span class="si">%s</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">ensemble</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">new_v</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">+=</span> <span class="s1">&#39;velocity all create </span><span class="si">%s</span><span class="s1"> </span><span class="si">%s</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">t_start</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">seed</span><span class="p">)</span>
        <span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">scale_v</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">+=</span> <span class="s1">&#39;velocity all scale </span><span class="si">%s</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">t_start</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dump</span><span class="p">:</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dump_name</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">+=</span> <span class="p">(</span><span class="s1">&#39;dump pysimm_dump all atom </span><span class="si">%s</span><span class="s1"> </span><span class="si">%s</span><span class="s1">.lammpstrj</span><span class="se">\n</span><span class="s1">&#39;</span>
                               <span class="o">%</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dump</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">dump_name</span><span class="p">))</span>
            <span class="k">elif</span> <span class="n">sim</span><span class="o">.</span><span class="n">name</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">+=</span> <span class="p">(</span><span class="s1">&#39;dump pysimm_dump all atom </span><span class="si">%s</span><span class="s1"> </span><span class="si">%s</span><span class="s1">.lammpstrj</span><span class="se">\n</span><span class="s1">&#39;</span>
                               <span class="o">%</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">dump</span><span class="p">,</span> <span class="s1">&#39;_&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">sim</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">split</span><span class="p">())))</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">+=</span> <span class="p">(</span><span class="s1">&#39;dump pysimm_dump all atom </span><span class="si">%s</span><span class="s1"> pysimm_dump.lammpstrj</span><span class="se">\n</span><span class="s1">&#39;</span>
                               <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">dump</span><span class="p">)</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dump_append</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">+=</span> <span class="s1">&#39;dump_modify pysimm_dump append yes</span><span class="se">\n</span><span class="s1">&#39;</span>
                
        <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">+=</span> <span class="s1">&#39;group p1 id {}</span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">p1</span><span class="o">.</span><span class="n">tag</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">+=</span> <span class="s1">&#39;group p2 id {}</span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">p2</span><span class="o">.</span><span class="n">tag</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">+=</span> <span class="s1">&#39;fix steer p1 smd cvel {} {} couple p2 auto auto auto {}</span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">k</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">v</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">d</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">+=</span> <span class="s1">&#39;run </span><span class="si">%s</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">length</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">+=</span> <span class="s1">&#39;unfix 1</span><span class="se">\n</span><span class="s1">&#39;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">+=</span> <span class="s1">&#39;unfix steer</span><span class="se">\n</span><span class="s1">&#39;</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dump</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">+=</span> <span class="s1">&#39;undump pysimm_dump</span><span class="se">\n</span><span class="s1">&#39;</span>

        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">input</span></div></div>
        


<div class="viewcode-block" id="Minimization"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.Minimization">[docs]</a><span class="k">class</span> <span class="nc">Minimization</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;pysimm.lmps.Minimization</span>

<span class="sd">    Template object to contain LAMMPS energy minimization settings.</span>

<span class="sd">    Attributes:</span>
<span class="sd">        min_style: LAMMPS minimization style default=&#39;sd&#39;</span>
<span class="sd">        dmax: how far any atom can move in a single line search in any dimension</span>
<span class="sd">        etol: energy tolerance default=1e-3</span>
<span class="sd">        ftol: force tolerance default=1e-3</span>
<span class="sd">        maxiter: maximum iterations default=10000</span>
<span class="sd">        max eval: maximum force evaluations default=100000</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">min_style</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;min_style&#39;</span><span class="p">,</span> <span class="s1">&#39;fire&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">dmax</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;dmax&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">etol</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;etol&#39;</span><span class="p">,</span> <span class="mf">1.0e-3</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">ftol</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;ftol&#39;</span><span class="p">,</span> <span class="mf">1.0e-3</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">maxiter</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;maxiter&#39;</span><span class="p">,</span> <span class="mi">10000</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">maxeval</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;maxeval&#39;</span><span class="p">,</span> <span class="mi">100000</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>

<div class="viewcode-block" id="Minimization.write"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.Minimization.write">[docs]</a>    <span class="k">def</span> <span class="nf">write</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sim</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;pysimm.lmps.Minimization.write</span>

<span class="sd">        Create LAMMPS input for an energy minimization simulation.</span>

<span class="sd">        Args:</span>
<span class="sd">            sim: :class:`~pysimm.lmps.Simulation` object reference</span>

<span class="sd">        Returns:</span>
<span class="sd">            input string</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">+=</span> <span class="s1">&#39;min_style </span><span class="si">%s</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">min_style</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">dmax</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">+=</span> <span class="s1">&#39;min_modify dmax </span><span class="si">%s</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">dmax</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">+=</span> <span class="p">(</span><span class="s1">&#39;minimize </span><span class="si">%s</span><span class="s1"> </span><span class="si">%s</span><span class="s1"> </span><span class="si">%s</span><span class="s1"> </span><span class="si">%s</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">etol</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">ftol</span><span class="p">,</span>
                                                   <span class="bp">self</span><span class="o">.</span><span class="n">maxiter</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">maxeval</span><span class="p">))</span>

        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">input</span></div></div>


<div class="viewcode-block" id="CustomInput"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.CustomInput">[docs]</a><span class="k">class</span> <span class="nc">CustomInput</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;pysimm.lmps.CustomInput</span>

<span class="sd">    Template object to contain custom LAMMPS input.</span>

<span class="sd">    Attributes:</span>
<span class="sd">        custom_input: custom input string</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">custom_input</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">input</span> <span class="o">=</span> <span class="s1">&#39;{}</span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">custom_input</span><span class="p">)</span>

<div class="viewcode-block" id="CustomInput.write"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.CustomInput.write">[docs]</a>    <span class="k">def</span> <span class="nf">write</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sim</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;pysimm.lmps.CustomInput.write</span>

<span class="sd">        Create LAMMPS input for a custom simulation.</span>

<span class="sd">        Args:</span>
<span class="sd">            sim: pysimm.lmps.Simulation object reference</span>

<span class="sd">        Returns:</span>
<span class="sd">            input string</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">input</span></div></div>


<div class="viewcode-block" id="Simulation"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.Simulation">[docs]</a><span class="k">class</span> <span class="nc">Simulation</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;pysimm.lmps.Simulation</span>

<span class="sd">    Organizational object for LAMMPS simulation. Should contain combination of</span>
<span class="sd">    :class:`~pysimm.lmps.MolecularDynamics`, :class:`~pysimm.lmps.Minimization`, and/or :class:`~pysimm.lmps.CustomInput` object.</span>

<span class="sd">    Attributes:</span>
<span class="sd">        forcefield: name of force field for simulation settings</span>
<span class="sd">        name: name for simulation</span>
<span class="sd">        log: LAMMPS log filename</span>
<span class="sd">        write: file name to write final LAMMPS data file default=None</span>
<span class="sd">        print_to_screen: True to have LAMMPS output printed to stdout after simulation ends</span>
<span class="sd">        debug: True to have LAMMPS output streamed to stdout during simulation (WARNING: this may degrade performance)</span>
<span class="sd">        custom: option to flag simulation as purley custom input to skip prepaing initialization</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">s</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">system</span> <span class="o">=</span> <span class="n">s</span>
        
        <span class="bp">self</span><span class="o">.</span><span class="n">forcefield</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;forcefield&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">forcefield</span> <span class="ow">is</span> <span class="bp">None</span> <span class="ow">and</span> <span class="n">s</span> <span class="ow">and</span> <span class="n">s</span><span class="o">.</span><span class="n">forcefield</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">forcefield</span> <span class="o">=</span> <span class="n">s</span><span class="o">.</span><span class="n">forcefield</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">debug</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;debug&#39;</span><span class="p">,</span> <span class="bp">False</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">print_to_screen</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;print_to_screen&#39;</span><span class="p">,</span> <span class="bp">False</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;name&#39;</span><span class="p">,</span> <span class="bp">False</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">log</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;log&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">write</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;write&#39;</span><span class="p">,</span> <span class="bp">False</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">custom</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;custom&#39;</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">_input</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">sim</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;sim&#39;</span><span class="p">,</span> <span class="p">[])</span>
        
<div class="viewcode-block" id="Simulation.add"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.Simulation.add">[docs]</a>    <span class="k">def</span> <span class="nf">add</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">):</span>
        <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">args</span><span class="p">:</span>
            <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="nb">basestring</span><span class="p">):</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">CustomInput</span><span class="p">(</span><span class="n">item</span><span class="p">))</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">item</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">item</span></div>
        
<div class="viewcode-block" id="Simulation.add_qeq"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.Simulation.add_qeq">[docs]</a>    <span class="k">def</span> <span class="nf">add_qeq</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">template</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;pysimm.lmps.Simulation.add_qeq</span>

<span class="sd">        Add :class:`~pysimm.lmps.Qeq` template to simulation</span>

<span class="sd">        Args:</span>
<span class="sd">            template: :class:`~pysimm.lmps.Qeq` object reference</span>
<span class="sd">            **kwargs: if template is None these are passed to :class:`~pysimm.lmps.Qeq` constructor to create new template</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="n">template</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">Qeq</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">))</span>
        <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">template</span><span class="p">,</span> <span class="n">Qeq</span><span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">template</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">error_print</span><span class="p">(</span><span class="s1">&#39;you must add an object of type Qeq to Simulation&#39;</span><span class="p">)</span></div>

<div class="viewcode-block" id="Simulation.add_md"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.Simulation.add_md">[docs]</a>    <span class="k">def</span> <span class="nf">add_md</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">template</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;pysimm.lmps.Simulation.add_md</span>

<span class="sd">        Add :class:`~pysimm.lmps.MolecularDyanmics` template to simulation</span>

<span class="sd">        Args:</span>
<span class="sd">            template: :class:`~pysimm.lmps.MolecularDynamics` object reference</span>
<span class="sd">            **kwargs: if template is None these are passed to :class:`~pysimm.lmps.MolecularDynamics` constructor to create new template</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="n">template</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">MolecularDynamics</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">))</span>
        <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">template</span><span class="p">,</span> <span class="n">MolecularDynamics</span><span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">template</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">error_print</span><span class="p">(</span><span class="s1">&#39;you must add an object of type MolecularDynamics to Simulation&#39;</span><span class="p">)</span></div>

<div class="viewcode-block" id="Simulation.add_min"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.Simulation.add_min">[docs]</a>    <span class="k">def</span> <span class="nf">add_min</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">template</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;pysimm.lmps.Simulation.add_min</span>

<span class="sd">        Add :class:`~pysimm.lmps.Minimization` template to simulation</span>

<span class="sd">        Args:</span>
<span class="sd">            template: :class:`~pysimm.lmps.Minimization` object reference</span>
<span class="sd">            **kwargs: if template is None these are passed to :class:`~pysimm.lmps.Minimization` constructor to create new template</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="n">template</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">Minimization</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">))</span>
        <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">template</span><span class="p">,</span> <span class="n">Minimization</span><span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">template</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">error_print</span><span class="p">(</span><span class="s1">&#39;you must add an object of type Minimization to Simulation&#39;</span><span class="p">)</span></div>

<div class="viewcode-block" id="Simulation.add_custom"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.Simulation.add_custom">[docs]</a>    <span class="k">def</span> <span class="nf">add_custom</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">custom</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;pysimm.lmps.Simulation.add_custom</span>

<span class="sd">        Add custom input string to simulation</span>

<span class="sd">        Args:</span>
<span class="sd">            custom: custom LAMMPS input string to add to Simulation</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">CustomInput</span><span class="p">(</span><span class="n">custom</span><span class="p">))</span></div>
       
    <span class="nd">@property</span> 
    <span class="k">def</span> <span class="nf">input</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">write_input</span><span class="p">()</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_input</span>

<div class="viewcode-block" id="Simulation.write_input"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.Simulation.write_input">[docs]</a>    <span class="k">def</span> <span class="nf">write_input</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">init</span><span class="o">=</span><span class="bp">True</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;pysimm.lmps.Simulation.write_input</span>

<span class="sd">        Creates LAMMPS input string including initialization and input from templates/custom input</span>

<span class="sd">        Args:</span>
<span class="sd">            None</span>

<span class="sd">        Returns:</span>
<span class="sd">            None</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_input</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
        
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">log</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_input</span> <span class="o">+=</span> <span class="s1">&#39;log {} append</span><span class="se">\n\n</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">log</span><span class="p">)</span>
        
        <span class="k">for</span> <span class="n">task</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">sim</span><span class="p">:</span>
            <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">task</span><span class="p">,</span> <span class="n">Init</span><span class="p">):</span>
                <span class="n">init</span> <span class="o">=</span> <span class="bp">False</span>

        <span class="k">if</span> <span class="n">init</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">custom</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">sim</span><span class="o">.</span><span class="n">insert</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">Init</span><span class="p">(</span><span class="n">forcefield</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">forcefield</span><span class="p">))</span>

        <span class="k">for</span> <span class="n">template</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">sim</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_input</span> <span class="o">+=</span> <span class="n">template</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
            
        <span class="bp">self</span><span class="o">.</span><span class="n">_input</span> <span class="o">+=</span> <span class="s1">&#39;write_dump all custom pysimm.dump.tmp id q x y z vx vy vz</span><span class="se">\n</span><span class="s1">&#39;</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">_input</span> <span class="o">+=</span> <span class="s1">&#39;quit</span><span class="se">\n</span><span class="s1">&#39;</span></div>

<div class="viewcode-block" id="Simulation.run"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.Simulation.run">[docs]</a>    <span class="k">def</span> <span class="nf">run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">np</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">nanohub</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">save_input</span><span class="o">=</span><span class="bp">True</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s1">&#39;mpiexec&#39;</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;pysimm.lmps.Simulation.run</span>

<span class="sd">        Begin LAMMPS simulation.</span>

<span class="sd">        Args:</span>
<span class="sd">            np: number of threads to use (serial by default) default=None</span>
<span class="sd">            nanohub: dictionary containing nanohub resource information default=None</span>
<span class="sd">            init: True to write initialization part of LAMMPS input script (set to False if using complete custom input)</span>
<span class="sd">            save_input: True to save input as pysimm.sim.in</span>
<span class="sd">            prefix: prefix for running LAMMPS (i.e. - mpiexec)</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">save_input</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span>
            <span class="k">with</span> <span class="nb">file</span><span class="p">(</span><span class="n">save_input</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
                <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">input</span><span class="p">)</span>
        <span class="k">elif</span> <span class="n">save_input</span> <span class="ow">is</span> <span class="bp">True</span><span class="p">:</span>
            <span class="k">with</span> <span class="nb">file</span><span class="p">(</span><span class="s1">&#39;pysimm.sim.in&#39;</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
                <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">input</span><span class="p">)</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="n">call_lammps</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">np</span><span class="p">,</span> <span class="n">nanohub</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="n">prefix</span><span class="p">)</span>
        <span class="k">except</span> <span class="ne">OSError</span> <span class="k">as</span> <span class="n">ose</span><span class="p">:</span>
            <span class="k">raise</span> <span class="n">PysimmError</span><span class="p">(</span><span class="s1">&#39;There was a problem calling LAMMPS with {}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">prefix</span><span class="p">)),</span> <span class="bp">None</span><span class="p">,</span> <span class="n">sys</span><span class="o">.</span><span class="n">exc_info</span><span class="p">()[</span><span class="mi">2</span><span class="p">]</span>
        <span class="k">except</span> <span class="ne">IOError</span> <span class="k">as</span> <span class="n">ioe</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">check_lmps_exec</span><span class="p">():</span>
                <span class="k">raise</span> <span class="n">PysimmError</span><span class="p">(</span><span class="s1">&#39;There was a problem running LAMMPS. The process started but did not finish successfully. Check the log file, or rerun the simulation with debug=True to debug issue from LAMMPS output&#39;</span><span class="p">),</span> <span class="bp">None</span><span class="p">,</span> <span class="n">sys</span><span class="o">.</span><span class="n">exc_info</span><span class="p">()[</span><span class="mi">2</span><span class="p">]</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="k">raise</span> <span class="n">PysimmError</span><span class="p">(</span><span class="s1">&#39;There was a problem running LAMMPS. LAMMPS is not configured properly. Make sure the LAMMPS_EXEC environment variable is set to the correct LAMMPS executable path. The current path is set to:</span><span class="se">\n\n</span><span class="s1">{}&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">LAMMPS_EXEC</span><span class="p">)),</span> <span class="bp">None</span><span class="p">,</span> <span class="n">sys</span><span class="o">.</span><span class="n">exc_info</span><span class="p">()[</span><span class="mi">2</span><span class="p">]</span></div></div>


<div class="viewcode-block" id="enqueue_output"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.enqueue_output">[docs]</a><span class="k">def</span> <span class="nf">enqueue_output</span><span class="p">(</span><span class="n">out</span><span class="p">,</span> <span class="n">queue</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;pysimm.lmps.enqueue_output</span>

<span class="sd">    Helps queue output for printing to screen during simulation.</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="nb">iter</span><span class="p">(</span><span class="n">out</span><span class="o">.</span><span class="n">readline</span><span class="p">,</span> <span class="sa">b</span><span class="s1">&#39;&#39;</span><span class="p">):</span>
        <span class="n">queue</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
    <span class="n">out</span><span class="o">.</span><span class="n">close</span><span class="p">()</span></div>


<div class="viewcode-block" id="call_lammps"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.call_lammps">[docs]</a><span class="k">def</span> <span class="nf">call_lammps</span><span class="p">(</span><span class="n">simulation</span><span class="p">,</span> <span class="n">np</span><span class="p">,</span> <span class="n">nanohub</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s1">&#39;mpiexec&#39;</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;pysimm.lmps.call_lammps</span>

<span class="sd">    Wrapper to call LAMMPS using executable name defined in pysimm.lmps module.</span>

<span class="sd">    Args:</span>
<span class="sd">        simulation: :class:`~pysimm.lmps.Simulation` object reference</span>
<span class="sd">        np: number of threads to use</span>
<span class="sd">        nanohub: dictionary containing nanohub resource information default=None</span>
<span class="sd">        prefix: prefix for running LAMMPS (i.e. - mpiexec)</span>

<span class="sd">    Returns:</span>
<span class="sd">        None</span>
<span class="sd">    &quot;&quot;&quot;</span>
    
    <span class="n">log_name</span> <span class="o">=</span> <span class="n">simulation</span><span class="o">.</span><span class="n">log</span> <span class="ow">or</span> <span class="s1">&#39;log.lammps&#39;</span>
    
    <span class="k">if</span> <span class="n">nanohub</span><span class="p">:</span>
        <span class="k">with</span> <span class="nb">file</span><span class="p">(</span><span class="s1">&#39;temp.in&#39;</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
            <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">simulation</span><span class="o">.</span><span class="n">input</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">simulation</span><span class="o">.</span><span class="n">name</span><span class="p">:</span>
            <span class="k">print</span><span class="p">(</span><span class="s1">&#39;</span><span class="si">%s</span><span class="s1">: sending </span><span class="si">%s</span><span class="s1"> simulation to computer cluster at nanoHUB&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%H:%M:%S&#39;</span><span class="p">),</span> <span class="n">simulation</span><span class="o">.</span><span class="n">name</span><span class="p">))</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">print</span><span class="p">(</span><span class="s1">&#39;</span><span class="si">%s</span><span class="s1">: sending simulation to computer cluster at nanoHUB&#39;</span> <span class="o">%</span> <span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%H:%M:%S&#39;</span><span class="p">))</span>
        <span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">flush</span><span class="p">()</span>
        <span class="n">cmd</span> <span class="o">=</span> <span class="p">(</span><span class="s1">&#39;submit -n </span><span class="si">%s</span><span class="s1"> -w </span><span class="si">%s</span><span class="s1"> -i temp.lmps -i temp.in &#39;</span>
               <span class="s1">&#39;lammps-09Dec14-parallel -e both -l none -i temp.in&#39;</span>
               <span class="o">%</span> <span class="p">(</span><span class="n">nanohub</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;cores&#39;</span><span class="p">),</span> <span class="n">nanohub</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;walltime&#39;</span><span class="p">)))</span>
        <span class="n">cmd</span> <span class="o">=</span> <span class="n">shlex</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="n">cmd</span><span class="p">)</span>
        <span class="n">exit_status</span><span class="p">,</span> <span class="n">stdo</span><span class="p">,</span> <span class="n">stde</span> <span class="o">=</span> <span class="n">RapptureExec</span><span class="p">(</span><span class="n">cmd</span><span class="p">)</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="k">if</span> <span class="n">simulation</span><span class="o">.</span><span class="n">name</span><span class="p">:</span>
            <span class="k">print</span><span class="p">(</span><span class="s1">&#39;</span><span class="si">%s</span><span class="s1">: starting </span><span class="si">%s</span><span class="s1"> LAMMPS simulation&#39;</span>
                  <span class="o">%</span> <span class="p">(</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%H:%M:%S&#39;</span><span class="p">),</span> <span class="n">simulation</span><span class="o">.</span><span class="n">name</span><span class="p">))</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">print</span><span class="p">(</span><span class="s1">&#39;</span><span class="si">%s</span><span class="s1">: starting LAMMPS simulation&#39;</span>
                  <span class="o">%</span> <span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%H:%M:%S&#39;</span><span class="p">))</span>
        <span class="k">if</span> <span class="n">np</span><span class="p">:</span>
            <span class="n">p</span> <span class="o">=</span> <span class="n">Popen</span><span class="p">([</span><span class="n">prefix</span><span class="p">,</span> <span class="s1">&#39;-np&#39;</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">np</span><span class="p">),</span>
                       <span class="n">LAMMPS_EXEC</span><span class="p">,</span> <span class="s1">&#39;-e&#39;</span><span class="p">,</span> <span class="s1">&#39;both&#39;</span><span class="p">],</span>
                      <span class="n">stdin</span><span class="o">=</span><span class="n">PIPE</span><span class="p">,</span> <span class="n">stdout</span><span class="o">=</span><span class="n">PIPE</span><span class="p">,</span> <span class="n">stderr</span><span class="o">=</span><span class="n">PIPE</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">p</span> <span class="o">=</span> <span class="n">Popen</span><span class="p">([</span><span class="n">LAMMPS_EXEC</span><span class="p">,</span> <span class="s1">&#39;-e&#39;</span><span class="p">,</span> <span class="s1">&#39;both&#39;</span><span class="p">],</span>
                      <span class="n">stdin</span><span class="o">=</span><span class="n">PIPE</span><span class="p">,</span> <span class="n">stdout</span><span class="o">=</span><span class="n">PIPE</span><span class="p">,</span> <span class="n">stderr</span><span class="o">=</span><span class="n">PIPE</span><span class="p">)</span>
        <span class="n">simulation</span><span class="o">.</span><span class="n">write_input</span><span class="p">()</span>
        <span class="k">if</span> <span class="n">simulation</span><span class="o">.</span><span class="n">debug</span><span class="p">:</span>
            <span class="k">print</span><span class="p">(</span><span class="n">simulation</span><span class="o">.</span><span class="n">input</span><span class="p">)</span>
            <span class="n">warning_print</span><span class="p">(</span><span class="s1">&#39;debug setting involves streaming output from LAMMPS process and can degrade performance&#39;</span><span class="p">)</span>
            <span class="n">warning_print</span><span class="p">(</span><span class="s1">&#39;only use debug for debugging purposes, use print_to_screen to collect stdout after process finishes&#39;</span><span class="p">)</span>
            <span class="n">p</span><span class="o">.</span><span class="n">stdin</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">simulation</span><span class="o">.</span><span class="n">input</span><span class="p">)</span>
            <span class="n">q</span> <span class="o">=</span> <span class="n">Queue</span><span class="p">()</span>
            <span class="n">t</span> <span class="o">=</span> <span class="n">Thread</span><span class="p">(</span><span class="n">target</span><span class="o">=</span><span class="n">enqueue_output</span><span class="p">,</span> <span class="n">args</span><span class="o">=</span><span class="p">(</span><span class="n">p</span><span class="o">.</span><span class="n">stdout</span><span class="p">,</span> <span class="n">q</span><span class="p">))</span>
            <span class="n">t</span><span class="o">.</span><span class="n">daemon</span> <span class="o">=</span> <span class="bp">True</span>
            <span class="n">t</span><span class="o">.</span><span class="n">start</span><span class="p">()</span>
    
            <span class="k">while</span> <span class="n">t</span><span class="o">.</span><span class="n">isAlive</span><span class="p">()</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">q</span><span class="o">.</span><span class="n">empty</span><span class="p">():</span>
                <span class="k">try</span><span class="p">:</span>
                    <span class="n">line</span> <span class="o">=</span> <span class="n">q</span><span class="o">.</span><span class="n">get_nowait</span><span class="p">()</span>
                <span class="k">except</span> <span class="n">Empty</span><span class="p">:</span>
                    <span class="k">pass</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="k">if</span> <span class="n">simulation</span><span class="o">.</span><span class="n">debug</span><span class="p">:</span>
                        <span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
                        <span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">flush</span><span class="p">()</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">stdo</span><span class="p">,</span> <span class="n">stde</span> <span class="o">=</span> <span class="n">p</span><span class="o">.</span><span class="n">communicate</span><span class="p">(</span><span class="n">simulation</span><span class="o">.</span><span class="n">input</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">simulation</span><span class="o">.</span><span class="n">print_to_screen</span><span class="p">:</span>
                <span class="k">print</span><span class="p">(</span><span class="n">stdo</span><span class="p">)</span>
                <span class="k">print</span><span class="p">(</span><span class="n">stde</span><span class="p">)</span>
                    
    <span class="n">simulation</span><span class="o">.</span><span class="n">system</span><span class="o">.</span><span class="n">read_lammps_dump</span><span class="p">(</span><span class="s1">&#39;pysimm.dump.tmp&#39;</span><span class="p">)</span>

    <span class="k">try</span><span class="p">:</span>
        <span class="n">os</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="s1">&#39;temp.lmps&#39;</span><span class="p">)</span>
    <span class="k">except</span> <span class="ne">OSError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
        <span class="k">print</span> <span class="n">e</span>
        
    <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="s1">&#39;pysimm.qeq.tmp&#39;</span><span class="p">):</span>
        <span class="n">os</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="s1">&#39;pysimm.qeq.tmp&#39;</span><span class="p">)</span>
        
    <span class="k">try</span><span class="p">:</span>
        <span class="n">os</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="s1">&#39;pysimm.dump.tmp&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">simulation</span><span class="o">.</span><span class="n">name</span><span class="p">:</span>
            <span class="k">print</span><span class="p">(</span><span class="s1">&#39;</span><span class="si">%s</span><span class="s1">: </span><span class="si">%s</span><span class="s1"> simulation using LAMMPS successful&#39;</span>
                  <span class="o">%</span> <span class="p">(</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%H:%M:%S&#39;</span><span class="p">),</span> <span class="n">simulation</span><span class="o">.</span><span class="n">name</span><span class="p">))</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">print</span><span class="p">(</span><span class="s1">&#39;</span><span class="si">%s</span><span class="s1">: simulation using LAMMPS successful&#39;</span>
                  <span class="o">%</span> <span class="p">(</span><span class="n">strftime</span><span class="p">(</span><span class="s1">&#39;%H:%M:%S&#39;</span><span class="p">)))</span>
    <span class="k">except</span> <span class="ne">OSError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
        <span class="k">if</span> <span class="n">simulation</span><span class="o">.</span><span class="n">name</span><span class="p">:</span>
            <span class="k">raise</span> <span class="n">PysimmError</span><span class="p">(</span><span class="s1">&#39;</span><span class="si">%s</span><span class="s1"> simulation using LAMMPS UNsuccessful&#39;</span> <span class="o">%</span> <span class="n">simulation</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">raise</span> <span class="n">PysimmError</span><span class="p">(</span><span class="s1">&#39;simulation using LAMMPS UNsuccessful&#39;</span><span class="p">)</span></div>


<div class="viewcode-block" id="qeq"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.qeq">[docs]</a><span class="k">def</span> <span class="nf">qeq</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">np</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">nanohub</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;pysimm.lmps.qeq</span>

<span class="sd">    Convenience function to call a qeq calculation. kwargs are passed to :class:`~pysimm.lmps.Qeq` constructor</span>

<span class="sd">    Args:</span>
<span class="sd">        s: system to perform simulation on</span>
<span class="sd">        np: number of threads to use</span>
<span class="sd">        nanohub: dictionary containing nanohub resource information default=None</span>

<span class="sd">    Returns:</span>
<span class="sd">        None</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">sim</span> <span class="o">=</span> <span class="n">Simulation</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
    <span class="n">sim</span><span class="o">.</span><span class="n">add_qeq</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
    <span class="n">sim</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="n">np</span><span class="p">,</span> <span class="n">nanohub</span><span class="p">)</span></div>


<div class="viewcode-block" id="quick_md"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.quick_md">[docs]</a><span class="k">def</span> <span class="nf">quick_md</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">np</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">nanohub</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;pysimm.lmps.quick_md</span>

<span class="sd">    Convenience function to call an individual MD simulation. kwargs are passed to MD constructor</span>

<span class="sd">    Args:</span>
<span class="sd">        s: system to perform simulation on</span>
<span class="sd">        np: number of threads to use</span>
<span class="sd">        nanohub: dictionary containing nanohub resource information default=None</span>

<span class="sd">    Returns:</span>
<span class="sd">        None</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">sim</span> <span class="o">=</span> <span class="n">Simulation</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
    <span class="n">sim</span><span class="o">.</span><span class="n">add_md</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
    <span class="n">sim</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="n">np</span><span class="p">,</span> <span class="n">nanohub</span><span class="p">)</span></div>


<div class="viewcode-block" id="quick_min"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.quick_min">[docs]</a><span class="k">def</span> <span class="nf">quick_min</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">np</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">nanohub</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;pysimm.lmps.quick_min</span>

<span class="sd">    Convenience function to call an individual energy minimization simulation. kwargs are passed to min constructor</span>

<span class="sd">    Args:</span>
<span class="sd">        s: system to perform simulation on</span>
<span class="sd">        np: number of threads to use</span>
<span class="sd">        nanohub: dictionary containing nanohub resource information default=None</span>

<span class="sd">    Returns:</span>
<span class="sd">        None</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">sim</span> <span class="o">=</span> <span class="n">Simulation</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
    <span class="n">sim</span><span class="o">.</span><span class="n">add_min</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
    <span class="n">sim</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="n">np</span><span class="p">,</span> <span class="n">nanohub</span><span class="p">)</span></div>
    
    
<div class="viewcode-block" id="energy"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.energy">[docs]</a><span class="k">def</span> <span class="nf">energy</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="nb">all</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span> <span class="n">np</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;pysimm.lmps.energy</span>

<span class="sd">    Convenience function to calculate energy of a given :class:`~pysimm.system.System` object.</span>

<span class="sd">    Args:</span>
<span class="sd">        s: system to calculate energy</span>
<span class="sd">        all: returns decomposition of energy if True (default: False)</span>
<span class="sd">        np: number of threads to use for simulation</span>

<span class="sd">    Returns:</span>
<span class="sd">        total energy or disctionary of energy components</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">sim</span> <span class="o">=</span> <span class="n">Simulation</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">log</span><span class="o">=</span><span class="s1">&#39;pysimm_calc.tmp.log&#39;</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
    <span class="n">sim</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">OutputSettings</span><span class="p">(</span><span class="n">thermo</span><span class="o">=</span><span class="p">{</span>
        <span class="s1">&#39;freq&#39;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
        <span class="s1">&#39;style&#39;</span><span class="p">:</span> <span class="s1">&#39;custom step etotal epair emol evdwl ecoul ebond eangle edihed eimp&#39;</span>
    <span class="p">}))</span>
    <span class="n">sim</span><span class="o">.</span><span class="n">add_md</span><span class="p">(</span><span class="n">length</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
    <span class="n">sim</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="n">np</span><span class="p">)</span>
    <span class="n">log</span> <span class="o">=</span> <span class="n">LogFile</span><span class="p">(</span><span class="s1">&#39;pysimm_calc.tmp.log&#39;</span><span class="p">)</span>
    <span class="k">try</span><span class="p">:</span>
        <span class="n">os</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="s1">&#39;pysimm_calc.tmp.log&#39;</span><span class="p">)</span>
    <span class="k">except</span><span class="p">:</span>
        <span class="n">error_print</span><span class="p">(</span><span class="s1">&#39;error likely occurred during simulation&#39;</span><span class="p">)</span>
    <span class="k">if</span> <span class="nb">all</span><span class="p">:</span>
        <span class="k">return</span> <span class="n">log</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">loc</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="k">return</span> <span class="n">log</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">loc</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">TotEng</span></div>
        

<div class="viewcode-block" id="check_lmps_attr"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.check_lmps_attr">[docs]</a><span class="k">def</span> <span class="nf">check_lmps_attr</span><span class="p">(</span><span class="n">s</span><span class="p">):</span>
    <span class="c1"># sync of the forcefield-style properties</span>
    <span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="s1">&#39;forcefield&#39;</span><span class="p">):</span>
        <span class="n">styles_list</span> <span class="o">=</span> <span class="n">FF_SETTINGS</span><span class="p">[</span><span class="s1">&#39;dreiding&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">keys</span><span class="p">()</span>
        <span class="k">if</span> <span class="n">s</span><span class="o">.</span><span class="n">forcefield</span> <span class="ow">in</span> <span class="n">FF_SETTINGS</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
            <span class="k">for</span> <span class="n">st_prop</span> <span class="ow">in</span> <span class="n">styles_list</span><span class="p">:</span>
                <span class="nb">setattr</span><span class="p">(</span><span class="n">s</span><span class="p">,</span> <span class="n">st_prop</span><span class="p">,</span> <span class="n">FF_SETTINGS</span><span class="p">[</span><span class="n">s</span><span class="o">.</span><span class="n">forcefield</span><span class="p">][</span><span class="n">st_prop</span><span class="p">])</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">warning_print</span><span class="p">(</span><span class="s1">&#39;Cannot synchronize given forcefield with LAMMPS representation types. &#39;</span>
                          <span class="s1">&#39;The forcefield is not present in the FF_SETTINGS of the pysimm.lmps module&#39;</span><span class="p">)</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="n">warning_print</span><span class="p">(</span><span class="s1">&#39;The forcefield attribute of the system is not defined. Some i/o methods of lmps &#39;</span>
                      <span class="s1">&#39;module will not be acessible&#39;</span><span class="p">)</span></div>


<div class="viewcode-block" id="LogFile"><a class="viewcode-back" href="../../pysimm.lmps.html#pysimm.lmps.LogFile">[docs]</a><span class="k">class</span> <span class="nc">LogFile</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;pysimm.lmps.LogFile</span>

<span class="sd">    Class to read LAMMPS log file into Pandas DataFrame stored in LogFile.data</span>

<span class="sd">    Attributes:</span>
<span class="sd">        fname: filename of log file</span>
<span class="sd">        data: resulting DataFrame with log file data</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fname</span><span class="p">):</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="n">pd</span><span class="p">:</span>
            <span class="k">raise</span> <span class="n">PysimmError</span><span class="p">(</span><span class="s1">&#39;pysimm.lmps.LogFile function requires pandas&#39;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">filename</span> <span class="o">=</span> <span class="n">fname</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">data</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">()</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_read</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">filename</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_read</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fname</span><span class="p">):</span>
        <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">fname</span><span class="p">)</span> <span class="k">as</span> <span class="n">fr</span><span class="p">:</span>
            <span class="n">copy</span> <span class="o">=</span> <span class="bp">False</span>
            <span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">fr</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">line</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s1">&#39;Step&#39;</span><span class="p">):</span>
                    <span class="n">strio</span> <span class="o">=</span> <span class="n">StringIO</span><span class="p">()</span>
                    <span class="n">copy</span> <span class="o">=</span> <span class="bp">True</span>
                    <span class="n">names</span> <span class="o">=</span> <span class="n">line</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
                <span class="k">elif</span> <span class="n">line</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s1">&#39;Loop&#39;</span><span class="p">):</span>
                    <span class="n">copy</span> <span class="o">=</span> <span class="bp">False</span>
                    <span class="n">strio</span><span class="o">.</span><span class="n">seek</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">pd</span><span class="o">.</span><span class="n">read_table</span><span class="p">(</span><span class="n">strio</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="s1">&#39;\s+&#39;</span><span class="p">,</span> <span class="n">names</span><span class="o">=</span><span class="n">names</span><span class="p">,</span> <span class="n">index_col</span><span class="o">=</span><span class="s1">&#39;Step&#39;</span><span class="p">))</span>
                <span class="k">elif</span> <span class="n">copy</span><span class="p">:</span>
                    <span class="n">strio</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">line</span><span class="p">)</span></div>

</pre></div>

           </div>
          </div>
          <footer>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2017, https://pysimm.org.

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  

    <script type="text/javascript">
        var DOCUMENTATION_OPTIONS = {
            URL_ROOT:'../../',
            VERSION:'0.2',
            COLLAPSE_INDEX:false,
            FILE_SUFFIX:'.html',
            HAS_SOURCE:  true
        };
    </script>
      <script type="text/javascript" src="../../_static/jquery.js"></script>
      <script type="text/javascript" src="../../_static/underscore.js"></script>
      <script type="text/javascript" src="../../_static/doctools.js"></script>

  

  
  
    <script type="text/javascript" src="../../_static/js/theme.js"></script>
  

  
  
  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.StickyNav.enable();
      });
  </script>
   

</body>
</html>